# Crontabs

# Format

*    *    *    *    *  command to be executed
┬    ┬    ┬    ┬    ┬
│    │    │    │    └─  Weekday  (0=Sun .. 6=Sat)
│    │    │    └──────  Month    (1..12)
│    │    └───────────  Day      (1..31)
│    └────────────────  Hour     (0..23)
└─────────────────────  Minute   (0..59)

# Examples

Cron Run
0 * * * * every hour
*/15 * * * * every 15 mins
0 */2 * * * every 2 hours
0 0 * * 0 every Sunday midnight
@reboot every computer start

# 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