Switching station at [Linux] ssh to run the program before and after adjustment

Original: https://my.oschina.net/huxuanhui/blog/13844

 

We all know that in Windows the above, we either make a program running in the background as a service or stop the service. And not allow the program to switch between foreground to background. The Linux provides fg and bg commands that allow us to easily schedule tasks are running.

Suppose you find a program running in the foreground take a long time, but need to do other things, you can use  Ctrl-the Z-  , suspend the program, and then you can see the system prompt (in brackets is the job number):

[1]+ Stopped /root/bin/rsync.shThen we can schedule the program to the background: (bg behind the numbers is job number) to view the running task with the jobs command: If you want to transfer it back to the foreground, you can use this, you can only be on the console waiting for this mission accomplished.#bg 1
[1]+ /root/bin/rsync.sh &
#jobs
[1]+ Running /root/bin/rsync.sh &
#fg 1
/root/bin/rsync.sh

fg, bg, jobs, &, ctrl + z are with system-related tasks, although it is basically not very need to use these commands, but also learn a very practical
one. & Most frequently used
this last used in a command, you can put this command into the background
II. ctrl + z
command being executed may be a foreground into the background, and pause
III. jobs
view the current number of commands run in the background
IV. fg
will command in the background adjusted foreground continue running
if there are multiple commands in the background, can be called up using the fg% jobnumber the selected command,% jobnumber command is a command by jobs found in the background being executed serial number (not the pid )
V. bg
will be a pause command in the background, becomes proceed
if there is more than one command in the background, can be called up using the bg% jobnumber the selected command,% jobnumber number command is found in the background by the jobs command being executed ( not pid)

Guess you like

Origin www.cnblogs.com/acm-icpcer/p/11221883.html