Running tasks on reboot with Cron

From emboxit
Revision as of 05:47, 1 November 2016 by NikoSysop (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  • Instructions created by Karl Maxwell 27/10/2016

Type in:

crontab -e

This will bring up a crontab window. Enter @reboot followed by a single command to have that command execute upon rebooting:

@reboot raspistill -o /home/pi/testImage.jpg

It is recommended that you use the full path. A single ‘&’ symbol at the end will make the command execute in the background. To run multiple commands consecutively, use ‘&&’ between commands.

@reboot cd /home/pi/apps && make run

In such a sequence, a command will only run if the previous command exits successfully. If error-checking is not required, string commands together separated with ‘:’. The changes above affect only the current user as this crontab is associated with that user. To edit the root crontab instead, use:

sudo crontab -e