Linux中crontab定时任务

crontab:可以实现分钟级别的精准任务调度
crontab -e : 编辑定时任务

* * * * * command
分钟 小时
00-59 00-23 1-31 1-12 0-7 sh /tmp/test.sh

-》每天凌晨3点执行脚本

00 03 * * * sh /tmp/test.sh

-》每周日中午12点30执行该程序

30 12 * * 7 sh /tmp/test.sh

-》每两个小时执行一次

00 */2 *	*	*  sh /tmp/test.sh

-》每天5点和7点执行一次

00 5,7 * * * sh /tmp/test.sh

-》每天5点到7点

00 5-7 * * * sh /tmp/test.sh

crontab -l :列举当前所有的定时任务
crontab -r : 删除所有的定时任务
crontab -u root -f /tmp/test.txt:
使用test.txt文件作为root用户的定时任务

猜你喜欢

转载自blog.csdn.net/lz6363/article/details/88778869