Linux Command background run

Source: Internet
Author: User
Tags autoload mysql in

1. Add &amp to the command after the order, and you can make the command work in the background, the greatest benefit is not afraid to be interrupted by the CTRL + C interrupt instruction.

2. Then you may ask again, how does the program in the background make it back to the foreground? It's simple, just use the FG command, and you can do it.

3. Some students may ask again, I have now run the command in the foreground, I can put it in the background to run it? Of course, as long as the implementation of CTRL + Z can be done. is not great Ah!

4. Speaking of some students may ask again, if I have more than one process in the background to run, then how to restore to the foreground to execute it? This is the time to use the jobs command, through the jobs command, to list all the processes executed in the background, the number in brackets ([]) is the name of jobs, and through FG%number can restore the specified background process.

Use Nohup to let programs run in the remote host background

Because I bought a foreign host actually opened Telnet permissions, so I also use Telnet login to play Linux, but found that a closed window automatically and the host disconnected, and the terminal is not the same, so on the Internet to find Ah, found a way to run a program from the background.

Unix/linux generally like to let a program run in the background, many use & at the end of the program to let the program run automatically. For example we want to run MySQL in the background:

/usr/local/mysql/bin/mysqld_safe–user=mysql &

But join us many programs do not like Mysqld as the Guardian process, perhaps our program is only ordinary program, generally this program uses & end, but if the terminal is closed, then the program will be closed. But in order to be able to run in the background, then we can use the Nohup command, such as we have a test.php need to run in the background, and want to be able to run periodically 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 the output information of the program running is put in the Nohup.out file of the current directory.

Attached: nohup Command Reference

Nohup command

Purpose: To run the command without hanging off.

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

Description: The nohup command runs commands specified by the command parameter and any related ARG parameters, ignoring all hang-up (SIGHUP) signals. Use the Nohup command to run a program in the background after logging off. To run [...] in the background

1. Two commands running in the background & and Ctr+z

At the beginning of the + "&" Specific method is: [Command] space [&]

Like what:

[[email protected] etc]# Find/-name XML &

This way, the Finder will run in the background. It runs without affecting you to do anything else.

But sometimes forget to add the ' & ' symbol after the command, and don't want to stop this command to rewrite it again. This is can press [Ctrl + Z], the current program into the background.

[[email protected] etc]# Find/-name XML

/etc/xml

/usr/lib64/python2.4/xml

/usr/share/vim/vim70/autoload/xml

/usr/share/hplip/data/xml

/usr/share/java-utils/xml

/usr/share/xml

/usr/share/doc/libvorbis-devel-1.1.2/xml

/usr/local/apache-tomcat-6.0.14/webapps/examples/jsp/xml

/webapp/web/jsp/xml

[[email protected] etc]# Find/-name XML

/etc/xml

/usr/lib64/python2.4/xml

/usr/share/vim/vim70/autoload/xml

/usr/share/hplip/data/xml

/usr/share/java-utils/xml

/usr/share/xml

[1]+ Stopped Find/-name XML

Note, however, that this program in the background is in the Stopped state (look at the last line above).

Use jobs to view the running program in the background.

[[email protected] etc]# jobs

[1]-Stopped Find/-name XML

[2]+ Stopped vi/etc/hosts

Can be used with the command BG 2. The effect is the same as in the beginning with the Find/-name xml&, so that the command runs in the background.

2. Back up the backstage program to the foreground

According to Jobs ' display, the corresponding program was recalled to the foreground with FG 2.


Linux Command background run

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.