1

After running a process, then using:

ctrl+z
bg
disown [-h]

Closing the connection still results in interrupting the running process.

  • 1
    nohup and screen are far better options. What process are you running and why are you so determined to use disown? – Alex Sep 14 '21 at 18:59
  • yeah i usually use nohup but the question is about a process that is already running – cookiemonster Sep 14 '21 at 19:02
  • the process is a python script to train a model that has been running for a while and i would prefer to not interrupt it at this point – cookiemonster Sep 14 '21 at 19:04
  • You can't disown a pid or process, you disown a job. Run jobs command and see if your script is there. Then run disown %jobnumber – Alex Sep 14 '21 at 19:10
  • yeah this is what i did. it still didn't work. i also checked jobs after disown – cookiemonster Sep 14 '21 at 19:12
  • jobs are empty but still closing the connection kills the process – cookiemonster Sep 14 '21 at 19:16
  • Possibly useful, depending on what your ultimate goal is: https://unix.stackexchange.com/q/4034/315749 – fra-san Sep 14 '21 at 19:55
  • why do you believe that disown would prevent that from happening? –  Sep 14 '21 at 22:39
  • 2
    Your background job would still die if a) it's stopped and it doesn't catch the SIGHUP signal b) it tries to write to the terminal which no longer exists, gets an error, and exits with an error message which goes nowhere c) systemd kills it (this was debated at long) or d) something else. nohup will only help with a). I suggest you attach to it from another terminal/ssh connection with strace -fp PID, and see what's actually happening. –  Sep 14 '21 at 23:55
  • 1
    @Alex a job is a process group. When you run foo &, or foo followed by Ctrl-Z and bg, you have foo as a job with a single process, and that's the job disown without arguments will remove from the bash's jobs table, without detaching it from the terminal or downgrading it from a job to a simple process or other nonsensical magical actions. –  Sep 15 '21 at 00:01
  • @UncleBilly thanks yeah it was actually writing to the terminal and i suspected it's the reason it got terminated after disconnecting. There were some comments like the ones under this answer https://unix.stackexchange.com/a/4010/374091 that got me thinking it should actually work – cookiemonster Sep 15 '21 at 07:05

0 Answers0