AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

nohup command: remove the HUP signal

PARTAGEZ

Using the Linux nohup command, your system ignores the hangup HUP command. Thus, the execution of a process can continue in the background. The result of this command is transferred to the file nohup.out or in another file of your choice.

What is Linux nohup?

To understand what the nohup command is, it is interesting to look at SIGHUP. This is a signal, especially generated in Linux, when a disconnection occurs on the data line between the operating system and another application. Depending on the situation, however, it may be useful if this signal is not sent. This is particularly the case when an application must also continue to function after the system user has logged out. To remove the signal and continue running the program in the backgroundyou must use Linux nohup.

How does the nohup command work?

The Linux nohup program is part of all standard Linux distributions, like Debian and Ubuntu, so there is no need to install it. You can instruct the system to launch a specific program in the background and thus, canceling the login shell. Any results are automatically transmitted to the file nohup.out. During tedious processes, this command has the advantage of being able to log you out without interrupting the process.

What is the syntax of Linux nohup?

The basic syntax of the nohup command is always the same. Here is the structure:

$ nohup [Commande] [Argument] [&]

bash

“ [Commande] ” And ” [Argument] » are parameters that can be adapted and specified. To continue running background processes even after logging out, use “ [&] “.

What are the options for the nohup command?

Linux nohup does not accept any options apart from the two standard options “-h” (or “–help”) and “-v” (or “–version”). The “-p” (or “–parents”) option is only allowed when you forego entering a parameter for “ [Commande] “.

Examples of using the nohup command

So that you better understand how the command works, we present some examples of use.

$ nohup bash exemple.sh

bash

This example triggers the command to execute in the foreground. The result of the command is automatically transmitted to the file nohup.out.

$ nohup bash exemple.sh > output.txt

bash

With this command you ensure that the results are transmitted in the document output.txt.

$ nohup bash exemple.sh &

bash

This command causes the command to continue running in the background. If you want to cancel it and retry the command in the foreground, go for the fg command.

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact