1753907 Members
8643 Online
108810 Solutions
New Discussion юеВ

background process

 
SOLVED
Go to solution
Shivkumar
Super Advisor

background process

Is there a command to check background running processes ? if yes then how to move them between foreground and background ?

thanks,
shiv
12 REPLIES 12
Rajeev  Shukla
Honored Contributor

Re: background process

jobs is the command to see how many jobs are in stoped state (means not running)

to move the job to background do
bg
to move the job to foreground run
fg
Arunvijai_4
Honored Contributor

Re: background process

Hi Shiv,

You can use "bg" and "fg". You can take a look at the man pages for more information.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor
Solution

Re: background process

Hi Shiv,

This link provides with Monitoring and Tracing Unix Processes on various Unix OS.

http://www.idevelopment.info/data/Unix/General_UNIX/GENERAL_MonitoringandtracingUnixprocesses.shtml

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Senthil Prabu.S_1
Trusted Contributor

Re: background process

Hi shiva,
to know the process running in background on unix machines, refer this link;
http://www.unixguide.net/unix/faq/3.7.shtml


And fg and bg are the commands to shift process between background and foreground.
One man's "magic" is another man's engineering. "Supernatural" is a null word.
Arunvijai_4
Honored Contributor

Re: background process

Hi Shiv,

You have to find the job number using job command. Then, You can do the following

To put the #999 job in the background
# bg %999

To would bring it back in the foreground.

# fg %999

-Arun


"A ship in the harbor is safe, but that is not what ships are built for"
Yogeeraj_1
Honored Contributor

Re: background process

hi shiv,

below more information on fg and bg:

fg [%]

and

bg [%]

The fg command can be used to restart the execution of a suspended or backgrounded command or program in foreground mode. With no arguments, the fg command causes the current job (the one shown in the output of the jobs command with a + sign next to it) to be resumed in foreground mode. The program will take control of your terminal, just as though you'd originally run it in the foreground. As always, you can resuspend the process by pressing CTRL-Z.

With a single argument consisting of a percent sign (%) and the job index of a backgrounded or suspended job (as listed by the jobs command), the fg command brings the specified process to the foreground, resuming it if it was previously suspended.

The bg command is analogous to the fg command, but allows you to resume a suspended process in background mode, rather than foreground mode. Like the fg command, the bg command will accept a single argument consisting of a percent sign and a job index, or, with no arguments, will operate on the current job.

In the example below, our YD resumes running his second terminal emulator window in the background, and resumes reading the manual page for the C shell in the foreground:

[18] YD@MYSERVER# jobs
[1] + Stopped man csh
[2] - Stopped /usr/bin/X11/xterm
[3] - Running /usr/bin/X11/xterm
[19] YD@MYSERVER# bg %2
[1] + Running /usr/bin/X11/xterm
[20] YD@MYSERVER# jobs
[1] - Stopped man csh
[2] + Running /usr/bin/X11/xterm
[3] - Running /usr/bin/X11/xterm
[21] YD@MYSERVER# fg %1
man csh
.
.
.

Note that the shell automatically prints a reminder message after each bg or fg command, to let you know what process has been resumed.

hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Muthukumar_5
Honored Contributor

Re: background process

Use bg to check the background process informations. To make them from background to foreground use fg.

# sleep 100&
# bg
# fg


it will give you the details.

--
Muthu
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: background process

Read ksh man page for Jobs part. It is all related to this question.

--
Muthu
Easy to suggest when don't know about the problem!
Arunvijai_4
Honored Contributor

Re: background process

Hi Shiv,

# man sh-posix

will give you all the details.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"