1

My question is same as the ones I already found on SO here, here and here. But, for me nohup doesn't work. compiling screen gives errors and for disown, Control+Z does not make the process "stopped".

I run a data generation binary which writes data into a file and also prints status messages on the screen (stdout). I tried the following

nohup ./sp2b <options for sp2b> > output &

When I logout of the terminal and login back, the process is already killed. I actually would like to time it as well, so want to do

nohup time ./sp2b <options for sp2b> > output &

Why is nohup not working in my case?

Community
  • 1
  • 1
Raghava
  • 947
  • 4
  • 15
  • 29
  • 1
    why are you compiling screen? it should be readily available through your package manager – Uku Loskit Aug 12 '13 at 08:39
  • like apt-get? I don't have admin privileges. So I would actually prefer nohup like solution. – Raghava Aug 12 '13 at 09:38
  • why you ampersanding in screen anyways ? load up screen ctrl a x - create a few sessions or one start your ob oopen a new session then do screen -d {detach } leave it to run ? - screen -r and its nuber to connect up again ctrl a 1 to go back to that screen and job without ampersand? – V H Aug 12 '13 at 10:43
  • @vahid: he does not have screen – Uku Loskit Aug 12 '13 at 10:44
  • 1
    Possible duplicate of [In Linux, how to prevent a background process from being stopped after closing SSH client](https://stackoverflow.com/q/285015/608639), [How to make a program continue to run after log out from ssh?](https://stackoverflow.com/q/954302/608639), [Run a command in a shell and keep running the command when you close the session](https://stackoverflow.com/q/431521/608639), etc. – jww May 06 '19 at 21:44

2 Answers2

1

maybe try something like this, instead of screen use tmux (a more modern alternative of screen), as you do not have root, we will install it locally.

mkdir tmp && cd tmp;
aptitude download tmux;
ar x tmux_*
tar xvf data.tar.gz

Now you can try ./usr/bin/tmux, hopefully you will have dependencies installed, tmux has only a few. This worked on my machine.

Uku Loskit
  • 40,868
  • 9
  • 92
  • 93
  • Thank you for the reply. I tried this, but tmux depends on libevent and that is not installed on our server. Although I can compile and generate the binary of libevent and place it locally, I don't think there is an option to make tmux look in that folder for libevent(?). Why do you think the nohup option is not working for me? – Raghava Aug 12 '13 at 21:49
  • yes, this is possible via changing the export `LD_LIBRARY_PATH` variable. you can set by `export LD_LIBRARY_PATH=/my/libevent/path:$LD_LIBRARY_PATH` – Uku Loskit Aug 12 '13 at 22:06
  • why the process is not responding to `NOHUP` and `suspend` signals, I do not know, i'm no expert. It's possible to explicitly ignore these signals though, the default behavior is to respect them. is this them program: http://dbis.informatik.uni-freiburg.de/index.php?project=SP2B ? – Uku Loskit Aug 12 '13 at 22:10
  • I tested it out with `/.sp2b_gen -t 5000000000000000` suspending works just fine for me, is this the right executable? – Uku Loskit Aug 12 '13 at 22:34
  • wow, thats a huge number, might takes days to finish. Yes, thats the executable that I am trying out with a lesser number as parameter. For suspending, did you do a control+z? – Raghava Aug 12 '13 at 22:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/35315/discussion-between-uku-loskit-and-raghava) – Uku Loskit Aug 12 '13 at 22:37
0

The problem with nohup is that if you don't send the output to > /dev/null 2>&1 then it will keep the output process opened (it will output to nohup.out). So if you close the terminal, you also close the output process.

Example:

nohup node somescrip.js >/dev/null 2>&1 &
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135