1

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!

RRRRRRRR
  • 21
  • 3
  • Guessing, you might need to escape the & – moinudin Jan 19 '21 at 01:40
  • Why would you ever use `nohup` in this circumstance? It doesn't do anything useful at all. – Charles Duffy Jan 19 '21 at 01: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). – Charles Duffy Jan 19 '21 at 01:42
  • 1
    So, `sh myjobs.sh 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. – Charles Duffy Jan 19 '21 at 01:42
  • ("no pid returns" is normal; printing the PID to the TTY is another thing that's only done by _interactive_ shells). – Charles Duffy Jan 19 '21 at 01:43
  • 1
    @moinudin, no, escaping the `&` is absolutely not correct. That would make the exact string `&` be passed as an argument to `myjobs.sh`. – Charles Duffy Jan 19 '21 at 01:44

0 Answers0