html tool

2017年6月9日星期五

crontab按秒钟来执行

参考:http://www.cnblogs.com/juandx/p/4992465.html

基本格式 :
*****command
分  时  日  月  周  命令
第1列表示分钟1~59 每分钟用*或者 */1表示


很多时候,我们计划任务需要精确到秒来执行,根据以下方法,可以很容易地以秒执行任务。
以下方法将每10秒执行一次
1
2
3
4
5
6
7
# crontab -e
* * * * * /bin/date >>/tmp/date.txt
* * * * * sleep 10/bin/date >>/tmp/date.txt
* * * * * sleep 20/bin/date >>/tmp/date.txt
* * * * * sleep 30/bin/date >>/tmp/date.txt
* * * * * sleep 40/bin/date >>/tmp/date.txt
* * * * * sleep 50/bin/date >>/tmp/date.txt
  
[popexizhi]
*/1 * * * * sudo /usr/sbin/ntpdate ntp.xxx.com
是每分钟执行一次,不是每秒钟啊:)

没有评论:

发表评论