我有一个脚本,我从浏览器运行元刷新,它在浏览器中没有任何问题,但它不会在cron中工作所以我可以做什么从cron运行每一秒?我知道睡眠我可以,但我必须在cron作业中创建几个cron选项卡,每次我必须运行脚本
有睡眠我怎么能每5秒运行一次这个脚本.
<meta http-equiv="refresh" content="5;url=test.php">
<?php
$res = mysql_query("SELECT * FROM tableA where st='0' order by id asc LIMIT 1");
$row = mysql_fetch_array($res);
$link= $row['wl'];
function getTitle($Url){
$str = file_get_contents($Url);
if(strlen($str)>0){
preg_match("/\<\/td\><\/tr\><tr\><td colspan\=2\>(.*)\<\/td\>/",$str,$title);
return $title[1];
}
}
getTitle($link);
?>
Run Code Online (Sandbox Code Playgroud)
只需添加到您的crontab
* * * * * for i in {0..59}; do curl http://your.domain.zone/page.html && sleep 1; done;
Run Code Online (Sandbox Code Playgroud)
for 因为cron的运行速度不能超过每分钟一次.