1、基本概念
crontab命令常见于Unix和类Unix的操作系统之中,用于设置周期性被执行的指令。该命令从标准输入设备读取指令,并将其存放于“crontab”文件中,以供之后读取和执行。crontab储存的指令被守护进程激活, crond常常在后台运行,每一分钟检查是否有预定的作业需要执行。这类作业一般称为cron jobs。
2、命令格式
1
2
3
4
5
6
7
8
| # Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed |
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
2.1、每月每天每小时的第 0 分钟执行一次 xxoo
0 * * * * xxoo
2.2、在 12 月份期间, 每天的早上 6 点到 12 点中,每隔 20 分钟执行一次 xxoo
*/20 6-12 * 12 * xxoo
2.3、周一到周五每天下午 5:00 xxoo
0 17 * * 1-5 xxoo
2.4、每月每天的午夜 0 点 20 分, 2 点 20 分, 4 点 20 分 xxoo
20 0-23/2 * * * xxoo
3、基本操作[……]
继续阅读