Nohup

Nohup

nohup is a Unix command that is used to run another command while suppressing the action of the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. It is most often used to run commands in the background as daemons. Output that would normally go to the terminal goes to a file called nohup.out if it has not already been redirected.

nohup is part of the GNU Coreutils.

Example

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

$ nohup abcd & $ exit

Below example shows how to redirect output to a file other than nohup.out.

$ nohup abcd > out.file &

Note that these methods prevent the process from being sent a 'stop' signal on logout, but if input/output is being received for these files, they will still hang the terminal [http://www.zsh.org/mla/users/2005/msg00152.html] . See Overcoming Hanging, below.

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

$ nohup nice abcd &

Existing jobs

Some shells (e.g. bash) provide a shell builtin that may be used to prevent SIGHUP being sent 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.

Overcoming Hanging

Nohuping backgrounded jobs is for example useful when logged in via SSH, since backgrounded jobs can cause the shell to hang on logout due to a race condition [http://www.snailbook.com/faq/background-jobs.auto.html] . This problem can also be overcome by redirecting all three I/O streams:

nohup myprogram > foo.out 2> foo.err < /dev/null &

Alternatives

There are other ways to accomplish the "keep program running while one logs out" ability. For example, you can run the program inside a GNU Screen-style screen multiplexer, and then detach the screen. The screen runs independently of the user's sessions, and can be reattached by any session of the user. This has the advantage of being able to continue to interact with the program once reattached (as opposed to nohup, which cannot reattach nohup'ed programs). A related alternative would be to run in a 'detachable' windows session such as that provided by VNC.

Another would be to use 'setsid' which will run a program in a new session.

External links

* [http://bama.ua.edu/cgi-bin/man-cgi?nohup+1 nohup from Solaris man pages]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • nohup — is a POSIX command to ignore the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. The HUP (hangup) signal is by convention the way a terminal warns depending processes of logout.… …   Wikipedia

  • Nohup — UNIX утилита, запускающая указанную команду с игнорированием сигналов потери связи (hangup) и увеличением приоритета для планировщика задач на 5; таким образом, команда будет продолжать выполняться в фоновом режиме и после того, как пользователь… …   Википедия

  • nohup — UNIX утилита, запускающая указанную команду с игнорированием сигналов потери связи (hangup)таким образом, команда будет продолжать выполняться в фоновом режиме и после того, как пользователь выйдет из системы. Если стандартным выводом (stdout)… …   Википедия

  • Nohup — est une commande Unix permettant de lancer un processus qui restera actif même après la déconnexion de l utilisateur l ayant initiée. Combiné à l esperluette qui permet le lancement en arrière plan, nohup permet donc de créer des processus s… …   Wikipédia en Français

  • nohup — est une commande Unix permettant de lancer un processus qui restera actif même après la déconnexion de l utilisateur l ayant initiée. Combiné à l esperluette qui permet le lancement en arrière plan, nohup permet donc de créer des processus s… …   Wikipédia en Français

  • Программы UNIX-подобных операционных систем — Это список популярных программ, работающих в операционных системах основанных на UNIX (POSIX совместимых). Некоторые из этих программ являются стандартными для UNIX подобных систем. Содержание 1 Системный софт 1.1 Общего назначения …   Википедия

  • SIGHUP — Описание: Потеря соединения с терминалом По умолчанию: завершение процесса коды SA SIGINFO (не имеет специфических кодов) В POSIX системах, SIGHUP  сигнал, посылаемый процессу для уведомления о потере соединения с управляющим терминалом …   Википедия

  • GNU Coreutils — GNU Core Utilities Тип Miscellaneous Utilities Разработчик GNU Project Написана на C Операционная система Unix подобные ОС Последняя версия 8.20 (23 октября 2012) …   Википедия

  • Yafc — Infobox Software name = yafc Yet Another FTP Client caption = developer = John Buswell released = ? frequently updated = yes programming language = ? operating system = Linux, UNIX/POSIX language = ? genre = FTP client license = GPL website =… …   Wikipedia

  • GNU Screen — mit Split Screen Basisdaten Aktuelle Version 4.0.3 (7. August 2008) …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”