-   Linux - Newbie (
-   -   job_id-How to find job_id of a running process (

deepclutch 12-09-2007 08:55 AM

job_id-How to find job_id of a running process
How to find job_id of a process bg'ed.i mean how to get the job_id for running "fg" command?
I tried pid,but fg command insists on job_id.please help me which command will display job_id.
thanks :)

matthewg42 12-09-2007 09:01 AM

jobs is a shell internal which lists running jobs controlled by that shell.

deepclutch 12-09-2007 09:05 AM

now how do i use fg and bg without job_id :? for eg; i invoked firefox from terminal without "&".now if i want to detach the process from shell,how can we achieve it :? i am aware of pid,but job id is something new for me :) thanks,waiting for reply :-|

matthewg42 12-09-2007 10:42 AM

A job is a concept which is only meaningful inside the shell. Please read the JOB CONTROL section of the bash manual page for an overview (search for upper case JON CONTROL).

When a shell is closed, any backgrounded jobs attached to that terminal are send a signal SIGHUP (hang up). Most programs will terminate when they receive this signal. A program may choose to do something else other than terminate on receiving SIGHUP. At least in Ubuntu, firefox seems to be one of these, so you can just bg the process and then close the terminal.

For programs which terminate when you close the terminal which they are attached to, you have a few options:
  1. When you start the program by prefixing it with "nohup", for example:

    nohup myprogrm &
  2. Run the program in GNU Screen. Screen lets you detach the shell from the terminal, and then re-attach it at a later date. This is particularly useful for programs like terminal-based IRC clients... For you can detach the screen session from the terminal which is funning locally, log out, go to work and ssh to your machine and then re-attach to the shell running the IRC client. :)
  3. You can use the disown shell internal to remove the job from the shell's process group. This means it will not be sent a SIGHUP when the terminal is closed.

deepclutch 12-10-2007 01:16 AM

yes.your explanation is what i needed ATM!thanks!:) and i am doubting with epiphany browser only! :D

All times are GMT -5. The time now is 04:11 AM.