在Debian系统中,你可以使用Crontab来实现循环任务
打开终端。
输入以下命令以编辑当前用户的Crontab文件:
crontab -e
* * * * * 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)
例如,如果你想让一个脚本每天凌晨1点执行,你可以这样写:
0 1 * * * /path/to/your/script.sh
*/语法。例如,如果你想让一个脚本每5分钟执行一次,你可以这样写:*/5 * * * * /path/to/your/script.sh
注意:确保你的脚本具有可执行权限。你可以使用以下命令为脚本添加可执行权限:
chmod +x /path/to/your/script.sh