#
Crontabs
#
Format
* * * * * command to be executed
┬ ┬ ┬ ┬ ┬
│ │ │ │ └─ Weekday (0=Sun .. 6=Sat)
│ │ │ └────── Month (1..12)
│ │ └─────────── Day (1..31)
│ └──────────────── Hour (0..23)
└───────────────────── Minute (0..59)
#
Examples
#
Gotchas
program not found
-> echo $PATH
and then inside the crontab Add
PATH=/etc/bin
// You can also use variables
APPLICATION_PATH=/full/path/to/app
// Recommend to wrap command into () brackets
// so you can reroute all output to a file
0 * * * * (cd $APPLICATION_PATH && node run server.js) >> /var/log/server.log 2>&1
Make sure the environment variables are correct
cat ~/.bashrc