The nohup command in AIX has the ability to nohup an existing process and protect if from hangup signals. Using the -p flag, an existing, running process can be nohuped and told to ignore SIGHUPs.

"Why is this useful?" I hear you ask.

Well, I'll often start a "long running" process on a system at work, like a backup for instance.I'll sometimes forget to use the nohup command, so that my long running job will ignore any SIGHUPs and continue running, say for example if my ssh session to the server dies. The nohup command also generates a nohup.out file to capture any messages (errors or otherwise) generated by the process e.g.

$ nohup ./processname &

$ ls l nohup.out

-rw------- 1 cgibson staff 0 May 26 19:42 nohup.out

In older releases of AIX, if I forgot to use nohup, I had two choices. I could either stop the process and start it again with nohup (often not desirable or possible) or I could leave my ssh session logged in on my work PC and hope that it didn't power down or crash or that my ssh connection did not drop over night.

Fortunately with more recent releases of AIX, this is not a problem anymore. If I forget to nohup a process, I can use the -p flag to inform the already running process that it should ignore all hangup (SIGHUP) signals. This will allow the process to continue running if my ssh session (terminal) dies and will also capture any output from the process into the nohup.out file, so I dont lose any important output from the process.

Heres an example. Im at work, it's 5pm and I've started a "long running" process named mycmd. This was started via an ssh (Putty) session from my PC.

$ ./mycmd

; Partial output from topas showing mycmd running.


mycmd 823432 98.8

; proctree output displaying PIDs associcated with mycmd and the associated ssh session (tty).

$ proctree 823432

520394 -ksh

585738 -ksh

823432 /home/cgibson/mycmd

I've walked out the door and I'm now on my way home for the evening.

Oh no! I've forgotten to start the process with nohup! I don't want to restart my process but I want to protect it from SIGHUPs, while it executes after hours.

No problem, I'll use nohup to modify the running process, so I can rest assured it will continue to run, even if my ssh connection drops over night. From home I start a new ssh session on the server and run nohup against the running process:

$ nohup -p 823432

At work the next morning, I discover that my original Putty session has indeed dropped! But, my process is still happily running! :)

; Partial output from topas showing mycmd still running.


mycmd 823432 99.3

$ proctree 823432




You might find this useful if you ever forget to nohup a process and dont want to restart it again.