没有&运行nohup当连接到远程服务器丢失时使脚本停止?

时间:2014-11-14 06:19:35

标签: php nohup

我正在运行一个脚本nohup php /var/www/html/foo.php我立即点击了输入,它给了我nohup: ignoring input and appending output to nohup.out'`

我的脚本正在使用pdo处理mysql记录

$dbh = new PDO('mysql:host=localhost;dbname=odesk', 'root', '');
$sth = $dbh->prepare("SELECT id,msisdn from new_tableu limit 91471,10");
$sth->execute();

while($result = $sth->fetch(PDO::FETCH_ASSOC)){
}

这是否意味着一旦互联网断开连接,我的脚本也会停止?

我可以在后台使用nohup php /var/www/html/foo.php &运行我的脚本,但它会永远运行,这不是我想要的。

1 个答案:

答案 0 :(得分:1)

将其保存为:

nohup php /var/www/html/foo.php

断开连接时不会出现中断。

我的建议是尝试 screen ,因为这样您可以断开连接然后重新连接并检查脚本输出

screen php /var/www/html/foo.php

通过这种方式,我运行了大量的脚本,需要几周才能完成,每天都会检查进度。