Tutorial: Detailed explanation of the usage of nohup command under Linux

888u

Last update at :2024-05-27,Edit by888u

Tutorial: Linuxnohup command When using Unix/Linux, we generally want a certain program to run in the background, so we will often use & at the end of the program to let the program run automatically. We have already written related articles about such general commands such as screen. Today we will introduce another method, which is also a command under Linux: nohup The role of nohup: The nohup command runs the command specified by the Command parameter and any related Arg parameters, ignoring all hangup (SIGHUP) signals. Use the nohup command to run programs in the background after logging out. To run a nohup command in the background, add & (the symbol for “and”) to the end of the command. Purpose: LINUX command usage, run the command without hanging up. nohup syntax

nohup Command [ Arg … ] [ & ]

nohup description

The nohup command runs the command specified by the Command parameter and any related Arg parameters, ignoring all hangup (SIGHUP) signals. Use the nohup command to run programs in the background after logging out. To run a nohup command in the background, add & (the symbol for “and”) to the end of the command. If you do not redirect the output of the nohup command, the output is appended to the nohup.out file in the current directory. If the nohup.out file in the current directory is not writable, output is redirected to the $HOME/nohup.out file. If no file can be created or opened for appending, the command specified by the Command parameter is not invoked. If standard error is a terminal, then all output of the specified command written to standard error is redirected to the same file descriptor as standard output.

nohup exit status

The command returns the following exit values: 126 The command specified by the Command parameter can be found but cannot be invoked. 127 An error occurred with the nohup command or the command specified by the Command parameter cannot be found. Otherwise, the exit status of the nohup command is the exit status of the command specified by the Command parameter. nohup command and its output files nohup command: If you are running a process and you feel that the process will not end when you log out of your account, you can use the nohup command. This command can continue to run the corresponding process after you log out of the account/close the terminal. nohup means no hang up. The general form of this command is: nohup command & Submit a job using the nohup command If you submit a job using the nohup command, all output from the job is redirected by default to a file named nohup.out, unless an output file is specified otherwise: nohup command > myout.file 2>&1 & In the above example, 0 – stdin (standard input), 1 – stdout (standard output), 2 – stderr (standard error); 2>&1 redirects standard error (2) to standard output (&1), and standard output (&1) is redirected to the myout.file file. Use jobs to view tasks. Use fg %n to close. There are two commonly used ftp tools ncftpget and ncftpput, which can realize ftp upload and download. We can use the nohup command to upload and download files in the background.

nohup command and its output files

nohup command: If you are running a process and you think the process will not end when you log out of your account, you can use the nohup command. This command can continue to run the corresponding process after you log out of the account/close the terminal. nohup means not to hang up (n ohang up).

The general form of this command is: nohup command &

Use the nohup command to submit the job

If you use the nohup command to submit a job, then by default all output of the job is redirected to a file named nohup.out, unless another output file is specified:

nohup command > myout.file 2>&1 &

In the above example, the output is redirected to the myout.file file.

Use jobs to view tasks.

Use fg %n to close.

There are also two commonly used ftp tools ncftpget and ncftpput, which can realize ftp upload and download in the background, so that you can use these commands to upload and download files in the background.

Recommended site search: permanent free vps cloud host, icp registration center, French proxy server, high-defense server rental, registration query Ministry of Industry and Information Technology, foreign cloud server, dual-line server hosting, Taiwan host, Chongqing server domain name registration query,

Tutorial: Detailed explanation of the usage of nohup command under Linux

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码