crontab以秒执行
十月 18th, 2010 Posted in Ubuntu | 阅读次数: 51
双线Linux服务器合租
Nginx服务器合租
Linux服务器合租64G超大内存
Author:gaojinbo
Time:2010-10-18
很多时候,我们计划任务需要精确到秒来执行,然而很多linux自带的版本都不直接支持以秒来执行,根据以下方法,可以很容易地以秒执行任务。
crontab每秒执行,crontab以秒执行,cron running every second,cron running every second
以下方法将每20秒执行一次
1.编辑crontab
crontab -e
* * * * * /bin/date >>/tmp/date.txt
* * * * * sleep 20; /bin/date >>/tmp/date.txt
* * * * * sleep 40; /bin/date >>/tmp/date.txt
2.检查结果
tail -f /tmp/date.txt
说明:需要将/bin/date更换成你的命令即可
完成!
Linux主机 PHP主机 Nginx主机 双线Linux服务器相关日志:
Tags: crontab
十月 18th, 2010 at 15:31
写得不错,很好,
一月 11th, 2011 at 11:46
不行啊,还是1分钟执行一次。啊,我写的是:
* * * * * sleep 2; /bin/date >>/tmp/date.txt
一月 11th, 2011 at 11:52
必须要有3行
* * * * * /bin/date >>/tmp/date.txt
* * * * * sleep 20; /bin/date >>/tmp/date.txt
* * * * * sleep 40; /bin/date >>/tmp/date.txt
二月 14th, 2011 at 12:01
其实crontab还是不支持秒,只不过执行的东西做了一下手脚而已,第一句执行一次,第二句睡眠20秒后执行,和第一句刚好隔开20秒,第三句睡眠40秒,和第二句刚好隔开20秒,然后过20秒刚好一分钟,又执行第一句,于是每20秒钟执行一次。想法还是不错的,赞一个。
五月 2nd, 2011 at 04:23
Favourite Sites…
[...]below you’ll see my links page http://www.pregnancymiraclez.net/my-favourite-sites/ with some great sites that I think you should visit[...]…
五月 12th, 2011 at 07:06
Interesting Article…
[...]some interesting sites worth visitng. We recommend all our readers go and check these out[...]……
六月 17th, 2011 at 05:10
Interesting Posts…
[...]some other related resources on the web that are worth viewing on this subject include[...]…
十月 28th, 2011 at 04:12
Pregnancy Miracle System…
[...]高进波博客 – 零起点一步配置你的linux服务器,linux博客,linux教程,web架构 » Blog Archive » crontab以秒执行[...]…