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