Wednesday, September 5, 2012

Change a running process to nohup

  1. put the process in the background (CTRL-Z)
  2. make sure it's still running though (bg)
  3. run disown -h

This doesn't really change to nohup, but it does prevent the job from receiving the SIGHUP signal when you exit the shell. Use the -a option to affect all jobs.

According to http://linux.about.com/library/cmd/blcmdl1_disown.htm:

disown [-ar] [-h] [jobspec ...]
    Without options, each jobspec is removed from the table of active jobs. If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return value is 0 unless a jobspec does not specify a valid job.

Followers