Does closure of Terminal stop remote script execution?

0

I have NAS (running Linux) and Macbook. What if I start the OSX Terminal application, connect to my NAS thru telnet and execute there some script:

python myscript.py > log.txt

Will it continue to run when I close the Terminal window? How should I run the script to continue its execution after Terminal closure? How to see script execution progress in such case (if don't redirect its output to some file)?

LA_

Posted 2015-01-05T20:49:11.643

Reputation: 536

Answers

1

  • "Will it continue to run when I close the Terminal window?": NO, but this happens because you launched your myscript.py in that specific way;

  • "How should I run the script to continue its execution after Terminal closure": you can prefix the command with NOHUP, so to explicitely tell your program to ignore the HUP signal it will receive (should the controlling terminal be closed). Also, if you program is in Uninterruptible Sleep state, then it will keep... sleeping (refusing any kill attempt), regardless of everything;

  • "How to see script execution progress in such case (if don't redirect its output to some file)?": execution by itself can be checked with normal "ps", "top", etc.; execution progress can be monitor mostly exclusively via your application-specific tracing messages (like, for example, writing tracing/log messages to SYSLOG).

Having said all the above, I kindly ask you to check this ServerFault question, dealing with remote SSH connection: I'm sure that things are absolutely the same when you're remotely connecting via telnet, as pseudo/controlling-terminal issues (that are the main factor determining the life of shell child processes) are the same in both SSH and TELNET remote connections.

Damiano Verzulli

Posted 2015-01-05T20:49:11.643

Reputation: 416

2

It won't continue to run.

You'll need to use something like screen to run it in a virtual terminal which you can reattach, or run it as a cron job which can run in the background.

Rots

Posted 2015-01-05T20:49:11.643

Reputation: 141

I'm sorry, but things are slighly more complex, expecially regarding the second and third part of the question. – Damiano Verzulli – 2015-01-05T21:42:09.810