Contents
Cron Job
* Don’t forget to set env when calling shell script from cron job.
# Create/edit crontab file crontab -e # List crontab file crontab -l # Remove crontab file crontab -r
Syntax
* * * * * command to execute min(0-59) hr(0-23) day of month(1-31) month of year(1-12) day of wk(0-6 with 0=Sunday)
* = all possible values
Examples
Every 3:15 am from Monday to Friday
15 3 * * 1-5 find $HOME -name core 2>/dev/null | xarg rm -f
Every five minutes
*/5 * * * * echo 'hello world'
Every First and Third Sunday at 1 am
0 1 1-7,15-21 * * [ `date +\%u` = 0 ] && /path/to/my_script.sh >> /path/to/my_script.log 2>&1