The Linux background running command (that is, the running command without hanging up) mainly uses the nohup command.
If the output of the nohup command is not redirected, the output will be appended to the nohup. out file in the current directory. If the nohup. out file in the current directory cannot be written, the output will be redirected to the $ HOME/nohup. out file. If no file can be created or opened for append, the Command specified by the Command Parameter cannot be called. If a standard error is a terminal, write the specified command to all outputs of the standard error as the standard output and redirect it to the same file descriptor.
Nohup command and its output file nohup command: If you are running a process and you think the process will not end when you exit the account, you can use the nohup command. This command can continue running the corresponding process after you exit the account/Close the terminal.
Example: nohup command> error. log
In the preceding example, the output is redirected to the error. log file of the current directory.
Some may ask again. If I have multiple processes running in the background, how can I restore them to the foreground for execution? At this time, the jobs command will be used. Through the jobs command, all processes executed in the background can be listed. The number in the brackets ([]) is the code of jobs, you can use fg % number to restore the specified background process.
To kill the background running program, you can use the top command to find the job id and then delete it.
Another way is to add & after the command to make the command work in the background. The advantage of this is that it is not afraid of being interrupted by the command ctrl + c. If you want to convert the command that is currently running on the foreground to the background, you only need to execute ctrl + z.
Articles you may be interested in
- How to run php files in the command line in windows
- How many lines of files can be viewed in linux?
- Linux File Content statistics command wc command usage details
- Linux chmod (file or folder permission setting) command parameters and Usage Details
- How to view the current running status of memcache through the command line
- Delete files in linux. Detailed explanation of the rm command for folder commands
- Common Windows running commands
- Graphic tutorial on common basic commands in Unix/Linux