How to get the program to execute in the background

Source: Internet
Author: User

Example: Viewing a script for system load

#!/bin/shwhiletruedo  uptime >/tmp/uptime. Log   Sleep 1 Done 
[Email protected] scripts]#Tail-f/tmp/Uptime. Log +:Panax Notoginseng: -Up5: the,2Users, load average:0.00,0.00,0.00Tail:/tmp/Uptime. LOG:filetruncated +:Panax Notoginseng: -Up5: the,2Users, load average:0.00,0.00,0.00Tail:/tmp/Uptime. LOG:filetruncated +:Panax Notoginseng: -Up5: the,2Users, load average:0.00,0.00,0.00Tail:/tmp/Uptime. LOG:fileTruncated

When we execute the script:

will appear in the login interface, unable to execute other commands, at this time if a network outage (user dropped) task will stop, so we are in the execution of the "&" symbol, meaning to execute in the background, when the user exits the task will still be executed.

sh test. SH  ^sh test. sh &[125352

But what happens when we want to stop the task?

sh test. sh &[125352[[email protected] scripts]# jobs[1]+  Running                 sh test.  SH &1    //For task number sh test.  SH^

What do we do when we want to turn the tasks performed at the foreground into background execution?

sh test. SH  ^z[1]+  Stopped                 sh test.  SH1         //1 is the task number [1sh test.  SH &[[email protected] scripts]# jobs[1]+  Running                 sh test.  SH &

Several ways to get the program to perform in the background:

1.sh test.sh &

2.screen

3.nohup test.sh &

How to get the program to execute in the background

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.