You have described that it is important to protect the continuation of the script. Unfortunately, I do not know if you are doing any interaction with script and script.
- continued protects the 'screen' command. your connection will break, but the screen will protect the pseudo-terminal, you can connect to it again, see a person.
if you don't need script interaction operators, you can just put the script in the background at the beginning and end the logging to the log file. Just use the command:
nohup /where/is/your.script.php >output.log 2&>1 &
output.log redirects the output to the log file, 2 &> 1 will add a stream of errors to the output, effectively to the log file. last & will put the command in the background. Note: the nohup command will disconnect the process from the terminal group.
Now you can safely exit the ssh shell. Since your script is outside the terminal group, it will not be killed. It will be returned from your shell process to the INIT system process. This is the unified behavior of the system. Full output that you can control with the command
tail -f output.log #allways breakable by ^C, it is only watching
Using this method, you do not need to use ^ Z, bg tricks, etc. To place a team in the background.
Note that using redirection to the nohup command is preferred. Otherwise, nohup will automatically redirect all outputs to the nohup.out file in the current directory.
source share