Table of Contents
Cron Automation
2016
This information comes from
“https://help.ubuntu.com/community/CronHowto“
To edit the cron job list:
crontab -e (don't sudo, or you will change root cron, not your user cron)
Then add your job, which has the format:
Each line has five time-and-date fields, followed by a command, followed by a newline character ('\n'). The fields are separated by spaces. The five time-and-date fields cannot contain spaces. The five time-and-date fields are as follows: minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday).
01 04 1 1 1 /usr/bin/somedirectory/somecommand\\
The above example will run /usr/bin/somedirectory/somecommand at 4:01am on January 1st plus every Monday in January.
An asterisk (*) can be used so that every instance (every hour, every weekday, every month, etc.) of a time period is used.
01 04 * * * /usr/bin/somedirectory/somecommand
Working Example
This example will run the script pibackup at 3am every Sunday
00 03 0 0 0 /mnt/usbstorage/backups/scripts/pibackup
Check if Cron is Running
/etc/init.d/cron status ● cron.service - Regular background program processing daemon Loaded: loaded (/lib/systemd/system/cron.service; enabled) Active: active (running) since Wed 2016-08-03 20:37:22 BST; 19h ago Docs: man:cron(8) Main PID: 453 (cron) CGroup: /system.slice/cron.service └─453 /usr/sbin/cron -f
Check Jobs
crontab -lu pi Shows current cron jobs for user pi