3

I treid to use nohup in python on cluster but failed. My code is here below:

import os path = "/ldfssz1/SP_MSI/USER/" os.system("nohup sh "+ path + "myjobs.sh &") 

Cluster only returns this:

nohup: ignoring input and appending output to `nohup.out' 

There were no pid returns and job command returns nothing. Can anyone gives me some idea what's going on here? Thank you very much!

6
  • Guessing, you might need to escape the & Commented Jan 19, 2021 at 1:40
  • Why would you ever use nohup in this circumstance? It doesn't do anything useful at all. Commented Jan 19, 2021 at 1:41
  • 1
    ...to expand on that, nohup does exactly two things: (1) it redirects any of stdin, stdout and stderr that would otherwise be going to a TTY; and (2) it turns off propagation of HUP signals (which are only TURNED ON in the first place for interactive shells, and os.system() creates noninteractive ones exclusively). Commented Jan 19, 2021 at 1:42
  • 1
    So, sh myjobs.sh </dev/null >nohup.out 2>nohup.out & does exactly the same thing, without nohup involved. But even then, that's a bunch of needless complexity, because there's no reason to involve an extra shell either. Commented Jan 19, 2021 at 1:42
  • 1
    @moinudin, no, escaping the & is absolutely not correct. That would make the exact string & be passed as an argument to myjobs.sh. Commented Jan 19, 2021 at 1:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.