Snochacz
Snochacz

Reputation: 725

ssh shell: disown script is not saving results to a file

I'm running a simple script in ssh shell. My script is doing some computations and at the end is saving results to a file. Because I cannot be connected to the shell I'm doing the following:

$ ./my_script.sh
Ctrl + Z 
$ bg 
$ disown

Then I "exit" and after logging in again sometimes script is still running, but if it's already done there should be an output file -- but it isn't there. If I don't leave the shell at all, everything works fine.

The most surprising thing is that I remember using Ctrl+Z, bg, disown commands in the past for the very same thing, and they worked fine.

I'm using open(file_name, 'w') in python to create the output file -- but I'm not sure if it's relevant.

Upvotes: 1

Views: 117

Answers (1)

John Kugelman
John Kugelman

Reputation: 362087

Also run disown -h to prevent the shell from sending the job a SIGHUP signal and killing it when the shell exits.

Upvotes: 1

Related Questions