- List cron jobs: crontab -l
- Edit cron jobs: crontab -e
- Delete cron jobs: crontab -r
minutes - 0-59
hours - 0-23
days of month - 1-31
months of year - 1-12
days of week - 0-6 (Sunday-Saturday)
Use '-' to indicate range for one time field, use ',' to separate a group of values for one time field, and use asterisk to indicate all possible value.
Examples:
If you need to run a job periodically, use this:
- 15 * * * * my_job
- 0,15,30,45 8-17 * * 1-5 my_job
*/10 * * * * my_jobIt means running my_job every 10 minutes. Even use SSH to invoke crontab, the jobs arranged run perfect after reboot the system.
On ubuntu, crontab for root:
$ sudo -i crontab -e
Remark: If one specifies upper slot, e.g. hours, he had better specify the lower slot whenever possible, e.g. minute; a potential disaster example, * 2 * * * my_job, the item will run every minute of 2:00 every day. Do not worry about privilege: the default crontab privilege is of the user who runs crontab for editing (adding) item.
没有评论:
发表评论