Ubuntu中的crontab(cron table)是一种用于定时执行任务的工具。它的基本语法格式如下:
* * * * * command-to-be-executed
- - - - -
| | | | |
| | | | ----- Day of the week (0 - 7) (Sunday to Saturday; 7 is also Sunday)
| | | ------- Month (1 - 12)
| | --------- Day of the month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
每个字段可以包含以下值:
以下是一些示例:
0 1 * * * command-to-be-executed
0 10 * * 0 command-to-be-executed
0 15 1,15 * * command-to-be-executed
要编辑crontab文件,请在终端中输入crontab -e命令。要查看当前用户的crontab列表,请输入crontab -l命令。