在Linux系统中,Crontab任务是用于设置周期性被执行的任务
* * * * * command-to-be-executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday to Saturday; 7 is also Sunday)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
要设置重复执行的任务,您需要根据需要替换星号(*)为适当的数字或范围。以下是一些示例:
* * * * * command-to-be-executed
0 1 * * * command-to-be-executed
0 15 * * 0 command-to-be-executed
0 10 1,15 * * command-to-be-executed
0 9-17 * * 1-5 command-to-be-executed
要编辑Crontab文件,请在终端中输入以下命令:
crontab -e
然后按照上述格式添加您的任务,保存并退出。这将设置您的Crontab任务以按照指定的时间间隔重复执行。