cron


Author: yifei / Created: May 29, 2017, 11:41 p.m. / Modified: May 29, 2017, 11:46 p.m. / Edit

crontabs are in the following format:

e.g. 5 * * * * echo "hello world" # every 5th minite of a hour

NOTE: number in cron means every i-th, not every.

* * * * *   every minute
12 * * * *  every 12th minute on the hour
0,15,30,45 * * * *  every 15 minutes
0 4 * * *   every day at 4:00am
0 4 * * 2   
*/4 2-6 * * *   every 15 minutes between 2 a.m. to 6 a.m.
@hourly/@daily/@weekly/monthly/@yearly  special syntax
@reboot at reboot

crontab should be edited with crontab

crontab -e # edit current user's crontab crontab -l # list current user's crontab crontab -u # another user's

NOTE:

add these line to tweak cron behavior

SHELL=/bin/bash HOME=/ MAILTO=”example@digitalocean.com”


评论区