将在没有的情况下运行nohup,并在与远程服务器的连接丢失时使脚本停止


Will running nohup without & make the script stop when connection to remote server is lost?

我正在运行一个脚本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 &但它永远运行,这不是我想要的。

保存

它以下列方式运行:

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

断开连接时不会有中断。

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

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

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