17

If I start a process with nohup:

nohup WHATEVER &

then how can I see it again? I mean how to attach my terminal to it again under Linux, e.g.: Ubuntu 11.04 - just like with the screen package.

slhck
  • 223,558
  • 70
  • 607
  • 592
LanceBaynes
  • 3,960
  • 23
  • 63
  • 92
  • I want to run a nohup job and to that already running process run a specific command (e.g. authentication). In fact the ideal solution would be to first run reauth command and the the real job **all under the same nohup process id**. So that the nohup processes never loses the kerberos ticket. So I want to run reauth to an already running nohup session automatically (i.e. without screen or tmux). How does one do that? – Charlie Parker Nov 14 '22 at 22:20

2 Answers2

7

What do you want to do with it?

As other poster has said, screen is better, you can attach/reattach.

nohup does not disconnect from terminal, it makes your app ignore SIGHUP, and (usually) redirects stdout/stderr. Run jobs in your terminal. It may just be a background job, and you can bring it back with fg. I don't know how to get stderr/stdout once you redirect it.

Rich Homolka
  • 31,057
  • 6
  • 55
  • 80
  • Once I close the ssh session, I do not see the process in the list of jobs and cannot `fg` it :-( Is there a remedy to this? – Lord Loh. Apr 01 '12 at 01:42
  • 1
    @LordLoh. no, once you disconnect with nohup, you can not reconnect. if you want to reconnect, try `screen` – Rich Homolka Apr 02 '12 at 15:32
  • I want to run a nohup job and to that already running process run a specific command (e.g. authentication). In fact the ideal solution would be to first run reauth command and the the real job **all under the same nohup process id**. So that the nohup processes never loses the kerberos ticket. So I want to run reauth to an already running nohup session automatically (i.e. without screen or tmux). How does one do that? – Charlie Parker Nov 14 '22 at 22:20
3

You should have used screen in the first place as it is a lot more flexible than nohup.

But if you want to attach to the process in the same way as screen, this link provides more info : https://serverfault.com/questions/24425/can-i-nohup-screen-an-already-started-process

Basically you can either use reptyr as described in the link, or you can use an old script called screenify. I found the script here : http://isteve.bofh.cz/~isteve/knowledgebase/articles/screenify.html

Sharken
  • 1,651
  • 11
  • 6
  • I want to run a nohup job and to that already running process run a specific command (e.g. authentication). In fact the ideal solution would be to first run reauth command and the the real job **all under the same nohup process id**. So that the nohup processes never loses the kerberos ticket. So I want to run reauth to an already running nohup session automatically (i.e. without screen or tmux). How does one do that? – Charlie Parker Nov 14 '22 at 22:20