Skip to main content
Share Your Experience: Take the 2024 Developer Survey
40 votes

Execute script on start-up

Add it to the crontab The crontab runs commands at defined times. Edit the file: sudo crontab -e Add line to file (here a python script): @reboot python3 /home/pi/Desktop/exemple.py &
Aaron's user avatar
  • 559
33 votes
Accepted

Setting timezone non-interactively

use timedatectl - for example sudo timedatectl set-timezone Australia/Sydney
Jaromanda X's user avatar
  • 2,425
16 votes

How do I know what version of Python script I'm writing?

how do I know what version of Python (2 or 3) I'm writing for Well, you should know because it is ultimately your decision! You pick one, you use the syntax of that particular generation, and you ...
Ghanima's user avatar
  • 15.9k
15 votes

Execute script on start-up

Autostarting xorg apps If the script you want to start requires an xorg session then you might try following the freedesktop autostart spec which might or might not work depending on which desktop ...
ccpizza's user avatar
  • 421
11 votes

Running multiple scripts from different languages

You can run any number of scripts with varying programming language. You can think in the direction of using tools like Screen or tmux. They basically are used to run scripts in background or detached ...
Shan-Desai's user avatar
  • 1,531
11 votes
Accepted

Running multiple scripts from different languages

Assuming that you're not running a weird custom operating system with a minimal kernel, the RPi is running a full fledged version of linux. The applications it comes with are written in C, C++, Java, ...
Jacobm001's user avatar
  • 11.9k
8 votes

Execute script on start-up

I want to throw in my two cents, even though this is an old question but commonly asked to do simple thing - autostart. I tried all the suggested solutions in all the answers for this question. NONE ...
ThN's user avatar
  • 1,063
7 votes

Running multiple scripts from different languages

I second Shan-Desai's suggestion of tmux, which is great, but perhaps this is actually overkill for your application. If neither of the scripts is in some way interactive, requires user input etc., ...
leftaroundabout's user avatar
6 votes

Execute script on start-up

NEW METHOD - RASPBERRY PI OS. This should work on other versions too. Create a desktop file xyz.desktop type the following into it [Desktop Entry] Encoding=UTF-8 Type=Application Name=<Application ...
Amr Sohil's user avatar
6 votes

Execute script on start-up

I also had trouble with this. On the Raspberry Pi3 running Raspbian this is what I did: Create a startup shell script in your root directory (I named mine "launch"): sudo leafpad launch.sh Save ...
lamarant's user avatar
  • 221
6 votes
Accepted

"bin/bash: bad interpreter: No such file or directory" when running shell script

A script is running without its interpreter when it is made executable and contains a shebang at the very first line. Because your script is running I assume that's the case with your script. But the ...
Ingo's user avatar
  • 42.2k
6 votes

Run a script at shutdown on Raspbian

If you are using systemd, just put your script to /lib/systemd/system-shutdown/ as described here and here. EDIT: If it's not working try this one: Create a systemd service: /etc/systemd/system/...
jake's user avatar
  • 1,347
5 votes

Checking if a given program is running

@SteveRobillard answered my question in the comments. I will re-iterate it here for everyone to see clearly! 1. Viewing running programs: In the terminal type: ps aux | grep programname ps = ...
Kookaburra's user avatar
5 votes

How do I know what version of Python script I'm writing?

I would probably base it on the library I need to use. I would always try to stick with Python 3 as it is the new version, but if a library I need has not been upgraded/converted, then I'll have to ...
Ricardo's user avatar
  • 1,048
5 votes

How to set up dashboard for monitoring PI processes

You could use "Munin" with Raspbian to monitor your RPis. You need only one "Munin Master" and on each device you want to monitor, the "Munin Node" software. "Munin" is very flexible and comes with ...
Fabian's user avatar
  • 1,280
5 votes
Accepted

Remote full reset (re-install) of a Raspberry

Firstly: doing this by remote is inadvisable especially if, like me, you happen to be 70+ miles from your remote pi. It's a very long drive if you screw it up. When you do this fir the first time, ...
Philip Couling's user avatar
5 votes

Monitoring NICs on the Pi

On Linux systems, there's a special file at /sys/class/net/$interface/carrier (where $interface is your interface name, e.g., eth0, wlan0). You can read from it like you would any other file in Python....
Brooke Chalmers's user avatar
5 votes
Accepted

Can't run python script on startup. Raspberry Pi 4

You've run into a well-known limitation with cron. The question has been asked and answered here many times. This recent example highlights the two (at least two) choices you have: use cron (older, ...
Seamus's user avatar
  • 22.2k
4 votes

Execute script on start-up

Method 1: To launch a command automatically on login, put the command into a file named .bashrc in the user directory (for example /home/pi) .bashrc is NOT intended to run scripts. It is ...
User98764431's user avatar
4 votes

Autorun Firefox on startup...grrrrrrr!

Ok I am giving a shot at this, try following the mentioned steps (type in your Terminal): create a folder called 'lxsession' in your hidden folder called .config: $ mkdir /home/pi/.config/lxsession ...
Shan-Desai's user avatar
  • 1,531
4 votes

Check system name and kernel version in script

Here's something which takes a different twist on /etc/os-release, which has a standardized format based around setting shell variables, meaning you can source it and use them. First have a look at ...
goldilocks's user avatar
  • 59.1k
4 votes
Accepted

How can I make AutoHotkey script work on Raspberry / alternative?

AutoHotKey is a windows scripting language. You cannot run it natively on a Linux operating system. It is technically possible to run it through WINE, but that hardly seems worth the effort, in my ...
Jacobm001's user avatar
  • 11.9k
4 votes

Running multiple scripts from different languages

No, there are no obvious reasons why you wouldn't be able to run two scripts in two languages at the same time. The Pi's just a very wee, relatively low-powered Linux machine and is perfectly capable ...
goobering's user avatar
  • 10.7k
4 votes

Visualize execution of scripts

Redirect output and errors to a file: myscript.sh >> /home/pi/log.txt 2>&1 &
CoderMike's user avatar
  • 6,997
4 votes

Include File With Raspbian Setup

Welcome, Lucas. I'm puzzled about your time trial. I don't see how you can put NOOBS on the micro SD card without copying... My advice would be to get a Pi built with the exact config you want (...
Jonathan's user avatar
  • 354
4 votes

My script in autostart not work correctly

ANSWER # 1: In looking at your script, I see a potential issue in the use of sudo. You may get away with this in Raspbian, but you won't in many other distributions (distros). This is due to the fact ...
Seamus's user avatar
  • 22.2k
4 votes
Accepted

Running a program on boot (Pi 4)

execute my bash script in order to invoke a program (e.g. open an instance of LXTerminal If your auto-started program needs anything graphical, then you're trying the wrong thing. Try putting it in ...
Botspot's user avatar
  • 1,779
4 votes
Accepted

Control fan to lower temperatur via script

The following answer addresses a Hardware and Software approach, and an Easier alternative requiring only hardware & a configuration change. This project may be of interest. The author uses a ...
Seamus's user avatar
  • 22.2k
3 votes
Accepted

Check system name and kernel version in script

You can try something like this. You may have to enhance this but the below script will work for you syntactically and also will tell which files to lookup and verify. #!/usr/bin/bash debian_version=...
Varad A G's user avatar
  • 848
3 votes

Restart mplayer stream process on loss of internet connection

mplayer -loop 0 stream_you_want_to_play -loop is not strictly designed for that, but it keeps trying to restart the stream after it is lost. Works here for stream drops, as well as just plain ...
jaaasgoed's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible