Tag Archives: raspberry

Autostart any Script using crontab

This guide is targeted at Raspian (Raspberry Pi) but it will work with most Linux distributions.

First, create your script using your editor of choice. Make sure you know the location of it!

nano superscript.sh


Make it executable:

chmod +x superscript.sh


Now edit your crontab file using this command:

crontab -e


Go to the bottom of the file and add the following line (lines starting with a # will be ignored):

@reboot sh /home/pi/superscript.sh > /home/pi/superscript-cronlog 2>&1
Tells crontab to execute this command after a boot
Uses sh to execute your script. Of course you can use any other shell too.
Path to your script
Writes the output of your script into the file specified on the right-hand side (green part)
Path to your log file
Makes sure that error messages (stderr) are also written to the log file. More information.


Reboot your computer and it should work!