Linux creates cron timing tasks

1. Created as current user

crontab -e

Create as specified user

sudo crontab -u <username> -e

2. Press Enter, open the configuration file in nano by default, and then add a task later

format

Example

* * * * * <执行目标的绝对路径>: 每分钟运行
0 * * * * <执行目标的绝对路径>: 每小时运行
0 0 * * * <执行目标的绝对路径>: 每天零点运行
0 7,15 * * * <执行目标的绝对路径>: 在每天的7:00和15:00运行
0 7-15 * * * <执行目标的绝对路径>: 在7:00到15:00的每个小时运行
0 7-15 * * 1-6 /<执行目标的绝对路径>: 周一到周六的7:00到15:00每小时运行
*/15 * * * * <执行目标的绝对路径>: 每15分钟运行。

If I want to execute /home/example.sh every 5 minutes, I write

*/5 * * * * bash /home/example.sh

nano press Ctrl + O to save, press Ctrl + X to exit

View the created cron tasks through commands

crontab -l

Guess you like

Origin blog.csdn.net/weixin_45579994/article/details/112386367