Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Use  





2 Implementations  





3 Overcoming hanging  





4 Alternatives  





5 References  





6 External links  














nohup






Čeština
Deutsch
Español
فارسی
Français

Italiano
Polski
Português
Русский
Українська

 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


nohup
Developer(s)Various open-source and commercial developers
Operating systemUnix, Unix-like, IBM i
PlatformCross-platform
TypeCommand

nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out.

Output that would normally go to the terminal goes to a file called nohup.out, if it has not already been redirected.

Use

[edit]

The first of the commands below starts the program abcd in the background in such a way that the subsequent logout does not stop it.

$ nohup abcd &
$ exit

Note that these methods prevent the process from being sent a 'stop' signal on logout, but if input/output is being received for these standard I/O files (stdin, stdout, or stderr), they will still hang the terminal.[1] See Overcoming hanging, below.

nohup is often used in combination with the nice command to run processes on a lower priority.

$ nohup nice abcd &

Implementations

[edit]

Some shells (e.g. bash) provide a shell builtin that may be used to prevent SIGHUP being sent or propagated to existing jobs, even if they were not started with nohup. In bash, this can be obtained by using disown -h job; using the same builtin without arguments removes the job from the job table, which also implies that the job will not receive the signal. Before using disown on an active job, it should be stopped by Ctrl-Z, and continued in the background by the bg command.[2] Another relevant bash option is shopt huponexit, which automatically sends the HUP signal to jobs when the shell is exiting normally.[3]

The AIX and Solaris versions of nohup have a -p option that modifies a running process to ignore future SIGHUP signals. Unlike the above-described disown builtin of bash, nohup -p accepts process IDs.[4]

The nohup command has also been ported to the IBM i operating system.[5]

Overcoming hanging

[edit]

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.[8]

Alternatives

[edit]
For example, the following invocation of screen will run somescript.sh in the background of a detached session:
$ screen -A -m -d -S somename ./somescript.sh &

References

[edit]
  1. ^ "Re: nohup/disown and logout". Zsh.org. 2005-02-07. Archived from the original on 2009-05-18. Retrieved 2009-06-10.
  • ^ Bash Reference Manual Archived 2010-12-03 at the Wayback Machine. Gnu.org. Retrieved on 2015-04-13.
  • ^ Bash Reference Manual Archived 2010-12-03 at the Wayback Machine. Gnu.org. Retrieved on 2015-04-13.
  • ^ IBM Knowledge Center Archived 2014-10-15 at the Wayback Machine. 01.ibm.com (2015-03-26). Retrieved on 2015-04-13.
  • ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Retrieved 2020-09-05.
  • ^ "SSH Frequently Asked Questions". Snailbook.com. Archived from the original on 2009-01-22. Retrieved 2009-06-10.
  • ^ "OpenSSH FAQ". Openssh.com. 2005-09-20. Archived from the original on 2009-07-10. Retrieved 2009-06-10.
  • ^ "Bug 396 – sshd orphans processes when no pty allocated". Bugzilla.mindrot.org. Retrieved 2009-06-10.
  • [edit]
    Retrieved from "https://en.wikipedia.org/w/index.php?title=Nohup&oldid=1177321298"

    Categories: 
    Unix SUS2008 utilities
    IBM i Qshell commands
    Hidden categories: 
    Webarchive template wayback links
    Articles with short description
    Short description is different from Wikidata
     



    This page was last edited on 27 September 2023, at 05:01 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki