I have written a script which essentially does 2 things:

  • Runs a UI for listening to the actual program running on the server
  • remotely run the program on the server

All goes well, the UI starts, then the program is run on the server. But as soon as I close the UI the remote process gets killed.

Relevant portions of the script:

ui_pid = subprocess.check_output('/home/user/git/sim_ui.sh', shell=True)
command = 'ssh user@server "bash -c \'cd program_dir/ && echo \"running program >> log.out && ./program.sh >> log.out\'"'
print command                                                                                       


nohup ui_binary args > ui_out.txt &

I also am unable to find out what killed the process on the server i.e. signal which terminated the process and where it originated from.

Edit: When I add screen -dm before bash -c it works perfectly.

  • I assume there is some kind of communication between the UI and the program running on the server? – koalo Jul 27 '18 at 8:27
  • @koalo Yes. But not of the kind where the remote program terminates upon closing the UI. When I add screen -dm before bash -c everything works perfectly. – user3286661 Jul 27 '18 at 8:30
  • I could not understand, what did happen when run nohup ui_binary args > ui_out.txt &? – Hossein Vatani Jul 27 '18 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.