2

I am attempting to run a program 'a.o' on a remote server. To keep it running after closing SSH connection, I tried the following:

setsid ./a.o
nohup ./a.o
./a.o &
disown -h %1

None of these options seem to work, and I cannot figure out why. Any ideas on how to fix this problem?

P.S. I am using a tunnel connection to connect to the server via a jump machine. Also, this is a program that involves CUDA code running on GPU. Do these have anything to do with the issue?

2
  • 2
    You can use a Terminal Multiplexer to keep processes running after logout. Both screen and tmux are quite good, and both are in the Ubuntu repositories.
    – user535733
    Sep 17, 2021 at 1:41
  • @user535733 Thanks a lot. I tried tmux and it worked! Sep 17, 2021 at 9:15

1 Answer 1

1

The nohup Wikipedia Page has a reference to this issue specifically:

Note that nohupping backgrounded jobs is typically used to avoid terminating them when logging off from a remote SSH session. A different issue that often arises in this situation is that ssh is refusing to log off ("hangs"), since it refuses to lose any data from/to the background job(s).[6][7] This problem can also be overcome by redirecting all three I/O streams:

$ nohup ./myprogram > foo.out 2> foo.err < /dev/null &

Also note that a closing SSH session does not always send a HUP signal to dependent processes, such as when a pseudo-terminal has not been allocated.

As mentioned in comments, screen and tmux are perfect for this too. Personally, I prefer tmux.

1
  • Thanks a lot! That solves my problem perfectly. And tmux works for me as well. Sep 17, 2021 at 9:14

Not the answer you're looking for? Browse other questions tagged .