国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP開發(fā) Use the nohup command to run Linux programs in the background

Use the nohup command to run Linux programs in the background

Nov 23, 2016 am 11:51 AM
nohup

Use nohup to make the program always run in the background

Under Unix/Linux, if you want a certain program to run in the background, many people use & at the end of the program to make the program run automatically. For example, we want to run mysql in the background:

/usr/local/mysql/bin/mysqld_safe --user=mysql &
But many of our programs are not made into daemons like mysqld. Maybe our programs are just ordinary programs. , generally this kind of program ends with &, but if the terminal is closed, the program will also be closed. But in order to be able to run in the background, we can use the nohup command. For example, if we have test.php that needs to be run in the background, and we want it to run regularly in the background, then use nohup:

nohup /root/test.php &
 Tips:

 [~]$ appending output to nohup.out

 Well, it proves that the operation is successful, and at the same time, the output information of the program operation is placed in the nohup.out file in the current directory.

Attached: nohup command reference

nohup command

Purpose: Run the command without hanging up.

Syntax: nohup Command [ Arg ... ] [ & ]

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.

  Regardless of whether the output of the nohup command is redirected to the terminal, the output will be 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.

Exit status: The command returns the following exit value:

126 The command specified by the Command parameter can be found but cannot be called.

 127 An error occurred in 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 file

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 not to hang up (n ohang up).

The general form of this command is: nohup command &

Use the nohup command to submit a job

If you use the nohup command to submit a job, then by default all output of the job will be redirected to a file called nohup.out file, unless an output file is specified otherwise:

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 I can use these commands to upload and download files in the background.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to shut down after running nohup command How to shut down after running nohup command Mar 18, 2024 pm 03:00 PM

Four methods: Find the process ID (PID) and kill the process using the "kill" command; kill all "nohup" processes using the "killall" command (use with caution); check the "nohup.out" file for relevant information. Through these methods, users can effectively shut down the tasks executed in the background by the "nohup" command.

Analysis of the function and principle of nohup Analysis of the function and principle of nohup Mar 25, 2024 pm 03:24 PM

Analysis of the role and principle of nohup In Unix and Unix-like operating systems, nohup is a commonly used command that is used to run commands in the background. Even if the user exits the current session or closes the terminal window, the command can still continue to be executed. In this article, we will analyze the function and principle of the nohup command in detail. 1. The role of nohup: Running commands in the background: Through the nohup command, we can let long-running commands continue to execute in the background without being affected by the user exiting the terminal session. This needs to be run

The difference between nohup and & The difference between nohup and & Mar 18, 2024 pm 02:48 PM

In Unix/Linux systems, nohup and && are both methods used to run commands or programs in the background. nohup is more suitable for long-running tasks because it is not affected by terminal status, can continue to execute, and can manage output. And && is suitable for short-lived background tasks, used when the results need to be checked later.

What does nohup mean? What does nohup mean? Mar 18, 2024 pm 03:14 PM

The nohup command is a tool used in Unix/Linux systems to execute commands in the background. Its function is to make the command ignore the hang-up signal and the execution will not be interrupted even if the terminal is closed. Usually, nohup will redirect the command output to the nohup.out file for subsequent viewing.

Detailed explanation of nohup command Detailed explanation of nohup command Oct 25, 2023 pm 04:20 PM

nohup is a commonly used command in Unix and Unix-like systems. It is used to run commands in the background and redirect the output of the command to a file to keep running even after the user logs out or the terminal is closed. Detailed explanation and usage of the nohup command: "nohup command [parameters] [input file] [output file]", where the command is the command to be run in the background, the parameters are the options and parameters of the command, and the input file is the input file of the command , the output file is the output file of the command.

Use nohup and & to improve process control efficiency Use nohup and & to improve process control efficiency Mar 25, 2024 pm 04:15 PM

In recent years, with the continuous development of information technology, most work cannot be done without the help of computers. During computer operation, we often encounter situations where multiple processes need to be run at the same time, and improving process control efficiency is very critical. This article will introduce how to use the nohup and & commands in Linux systems to improve process control efficiency. 1. Understand the nohup and & commands. In Linux systems, nohup is a command used to ignore the hang signal. It can make the command run in the background, even if the user exits the terminal.

How to use the linux nohup command to enable the program to continue running in the background after exiting the terminal How to use the linux nohup command to enable the program to continue running in the background after exiting the terminal May 26, 2023 am 09:48 AM

Under Unix/Linux, you generally want a program to run in the background. Many people use & at the end of the program to make the program run automatically; but if you want the program to still run in the background after exiting the terminal, you need to use nohup and & combination to achieve. Nohup command purpose: run the command without hanging up Syntax: nohupCommand[Arg...][&] 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 a program in the background after logging out: To run the nohup command in the background, you need to add & to the end of the command. day

How to correctly use nohup for background task processing How to correctly use nohup for background task processing Mar 26, 2024 am 09:39 AM

How to correctly use nohup for background task processing In daily work, we often need to perform some time-consuming tasks, such as file copying, data processing, etc. In order not to affect our work efficiency and ensure that tasks can run stably in the background, we can use the nohup command to start these tasks. This article will introduce how to correctly use nohup for background task processing. What is nohup command? nohup is a command in Unix and Unix-like operating systems that is used to run commands or scripts in the background.

See all articles