PHP script is killed without explanation

前端 未结 5 708
失恋的感觉
失恋的感觉 2021-01-19 17:22

I\'m starting my php script in the following way:

bash  
cd \'path\'   
php -f \'scriptname\'.php

There is no output while the php script i

5条回答
  •  隐瞒了意图╮
    2021-01-19 17:56

    http://en.wikipedia.org/wiki/Nohup

    Try using nohup before your command.

    nohup catches the hangup signal while the ampersand doesn't (except the shell is confgured that way or doesn't send SIGHUP at all).

    Normally, when running a command using & and exiting the shell afterwards, the shell will terminate the sub-command with the hangup signal (kill -SIGHUP ). This can be prevented using nohup, as it catches the signal and ignores it so that it never reaches the actual application.

    In case you're using bash, you can use the command shopt | grep hupon to find out whether your shell sends SIGHUP to its child processes or not. If it is off, processes won't be terminated, as it seems to be the case for you.

    There are cases where nohup does not work, for example when the process you start reconnects the NOHUP signal.

    nohup php -f 'yourscript'.php
    

提交回复
热议问题