Run commands on the Linux background (run without hanging up)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.