Linux/unix is a real multi-user, multitasking.
Linux provides FG and BG commands that let you easily schedule tasks that are running.
Suppose you find that a program running in the foreground takes a long time, but you need to do something else, you can hang up the program with Ctrl-z, and then you can see the system prompt:
[1]+ stopped/root/bin/rsync.sh
Then we can schedule the program to execute in the background: (the number behind BG is the job number)
#bg 1
[1]+/root/bin/rsync.sh &
Use the Jobs command to view the tasks that are running:
#jobs
[1]+ running/root/bin/rsync.sh &
If you want to bring it back to the foreground, you can use
#fg 1
/root/bin/rsync.sh
This way, you can only wait for the task to complete on the console.
& Throw instructions into the background to execute
[Ctrl]+z pauses the foreground task in the background
Jobs-l viewing the working status of the background
FG%jobnumber The backstage task to the front desk for processing.
BG%jobnumber put tasks in the background to handle
Kill management tasks in the background
Cases:
a:192.168.0.1 b:192.168.0.2
[A]nohup rsync-e ssh-avr/data1 192.168.0.2:/data1
nohup:appending output to ' nohup.out '
Password:
After entering the password, press: CTRL + Z
[1]+ Stopped nohup rsync-e ssh-avr/data1 192.168.0.2:/data1
Then enter it immediately:
[a]$ BG
The above command can then resume running in the background.
[1]+ nohup rsync-e ssh-avr/data1 192.168.0.2:/data1
Nohup to continue running in the background after entering the password