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
命令。