I am currently running mathematica on a Linux cluster, I want the job running stably even if I log out. So I use nohup. However, I found sometimes nohup terminates without any sign (I can't see any error message in the output file, it just stopped in the middle of a calculation.)

It maybe due to Mathematica. But I think maybe I should try screen. So I came up with this question. What is the difference between nohup and nohup in a screen? Will nohup inside a screen more stable than merely nohup?


It will not make a real difference, in the sense that if you run screen (or tmux) and you disconnnect there will be NOHUP signal sent to your application whether you start it with nohup or not.

I suggest you try it out by using screen/tmux and just start the program without nohup. Then forecfully disconnect, login and again and reattach to the previous session. You'll see that your session just keeps on working and that you can see its output (scrolling back in the buffer requires some special commands) and that you can (probably) interrupt the running program by pressing Ctrl+C, essentially as if you never disconnected.

So where your original program somehow terminates unexpectedly and hopefully writes to nohup.out what is the cause, now that output goes to the screen session buffer. But if it doesn't output anything when using nohup you will not get more information when running inside screen. It is not nohup that terminates, it is your program that does, despite running "under" nohup.

  • Hi, Anthon. Thank you for answering. I don't understand " if it doesn't output anything when using nohup you will not get more information when running inside screen". If all the output including error are redirected to file, what else am I missing from nohup.out? – user15964 Apr 30 '16 at 7:22
  • 1
    @user15964 I really think your program crashes without generating any output for some unknown reason and that it doesn't write a termination message before it does so. Otherwise it would be in the nohup.out (or any file you use for redirecting). Running under screen is not going to help you there. – Anthon Apr 30 '16 at 7:50
  • Sorry for my unclear post. Actually my program generate outputs at first, however sometimes it just stopped in the middle without any error message. Just "peacefully" stopped without any traceable info. Ok, I want to make sure one point: Is nohup at the same safety level as screen in terms of background job stability? – user15964 Apr 30 '16 at 8:12
  • @user15964 Yes it is at the same level. – Anthon Apr 30 '16 at 8:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.