Playing the commands fg , ctrl+z , bg and jobs
1. If you want to run a process in bacground just add a & as suffix with a space
Eg:
[root@localhost kannan]# ruby test.rb &
here this process test.rb will run in background
2. If you want list available background tasks/processes/jobs , just use the command 'jobs'
Eg:
[root@localhost kannan]# jobs
here the result would be
[1]+ Running ruby test.rb
3. If you want to bring a background process in front (foreground) just use fg [#<job number>]
Eg
[root@localhost kannan]# fg #1
It will bring the above 'ruby test.rb' process in front.
4. If you want to again move a already running process to background , use two combination of commands
a. First pass Ctrl+Z , here you will get a message like 'stopped' don't get upset, it will just suspend
b. Do run 'bg' command will take the suspended process/job/task to background process
Eg
[root@localhost kannan]# jobs
[1]+ Running ruby test.rb &
[root@localhost kannan]# fg #1
ruby test.rb
^Z
[1]+ Stopped ruby test.rb
[root@localhost kannan]# bg
[1]+ ruby test.rb &
[root@localhost kannan]#
Comments
Post a Comment