Linux background run Nohup & Ctrl + Z

Source: Internet
Author: User

When using Linux, it is often desirable that some command results not be displayed in the foreground, such as SH scripts, time-consuming commands, etc.
In general, use & to run the command results in the background, such as SH test.sh, script background execution.

Sometimes the command has been executed in the foreground, you need to switch it to the background can be used, CTRL + Z, but the command to switch to the background will be in a paused state, you can cooperate with jobs to further process the background commands (process).

The more extreme situation is that some commands take a long time but cannot be interrupted, such as downloading ... , the nohup (ignoring hangup signals) is required to ignore the pending signal being executed in the background.

Comparison of & with Nohup:
&: Run in the background, but when the user terminal exits (disconnected), the command ends
Nohup test.sh &: Running in the background, when the user terminal exits (the disconnection) remains in operation, the standard input and output can be used.

If you submit a job using the Nohup command, all output from the job is redirected to a file named Nohup.out by default, unless the output file is specified separately:
such as: Nohup command > Myout.file 2>&1 &
Specified output to file Myout.file
2>&1 is redirecting standard errors to standard output, where the standard output has been redirected to the Out.file file, and the standard error is output to the Out.file file. The last & is to have the command execute in the background.

Use examples to refer to:

Https://www.cnblogs.com/MYSQLZOUQI/p/5283761.html

Linux background run Nohup & Ctrl + Z

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.