Linux crontab 实现每秒执行
* * * * * php /home/fdipzone/php/crontab/tolog.php
* * * * * sleep 10; php /home/fdipzone/php/crontab/tolog.php
* * * * * sleep 20; php /home/fdipzone/php/crontab/tolog.php
* * * * * sleep 30; php /home/fdipzone/php/crontab/tolog.php
* * * * * sleep 40; php /home/fdipzone/php/crontab/tolog.php
* * * * * sleep 50; php /home/fdipzone/php/crontab/tolog.php
|
fdipzone
@ubuntu :~$ tail -f /home/fdipzone/php/crontab/run.log
2014-03-31 21:47:01
2014-03-31 21:47:11
2014-03-31 21:47:21
2014-03-31 21:47:31
2014-03-31 21:47:41
2014-03-31 21:47:51
2014-03-31 21:48:01
|
crontab.sh
#!/bin/bash
step=2 #间隔的秒数,不能大于60
for (( i = 0; i < 60; i=(i+step) )); do
$(php ‘/home/fdipzone/php/crontab/tolog.php‘)
sleep $step
done
exit 0
|
fdipzone
@ubuntu :~/php/crontab$ tail -f run.log
2014-03-31 22:23:01
2014-03-31 22:23:03
2014-03-31 22:23:06
2014-03-31 22:23:08
2014-03-31 22:23:10
2014-03-31 22:23:12
2014-03-31 22:23:14
2014-03-31 22:23:16
2014-03-31 22:23:18
2014-03-31 22:23:20
2014-03-31 22:23:22
2014-03-31 22:23:25
2014-03-31 22:23:27
2014-03-31 22:23:29
2014-03-31 22:23:31
2014-03-31 22:23:33
2014-03-31 22:23:35
2014-03-31 22:23:37
2014-03-31 22:23:39
2014-03-31 22:23:41
2014-03-31 22:23:44
2014-03-31 22:23:46
2014-03-31 22:23:48
2014-03-31 22:23:50
2014-03-31 22:23:52
2014-03-31 22:23:54
2014-03-31 22:23:56
2014-03-31 22:23:58
2014-03-31 22:24:00
|
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。