在Debian系统中,使用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)
以下是一些示例:
* * * * * /path/to/command
0 1 * * * /path/to/command
0 1 1 * * /path/to/command
0 1 * * 0 /path/to/command
要编辑当前用户的crontab文件,请在终端中输入以下命令:
crontab -e
要查看当前用户的crontab文件,请在终端中输入以下命令:
crontab -l
如果要删除当前用户的所有crontab任务,请在终端中输入以下命令:
crontab -r
请注意,根据任务的实际需求,您可能需要使用绝对路径来指定命令。