LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to show the list of stopped and background jobs (https://www.linuxquestions.org/questions/linux-general-1/how-to-show-the-list-of-stopped-and-background-jobs-433273/)

fakhrul 04-09-2006 04:02 AM

How to show the list of stopped and background jobs
 
what command can give me the list of stopped jobs and the programs that are running background e.g running a program by the command play sound.wav & and jobs stoped by ctrl-Z. i know the fg command now i want to know the list of stopped jobs as i can merely do fg of my own choice.

truthfatal 04-09-2006 04:29 AM

use "jobs" it lists all backgrounded processes.
then "fg [number]"


eg:
Code:

$jobs
[1]    Stopped    vim
[2]-    Running    play sound.wav &
[3]+    Stopped    man ps            # the plus sign means this process will be foregrounded if you just type fg without a number

$fg 1    #this would bring vim back to the foreground

*taken from the Slackware Book

fakhrul 04-12-2006 03:32 AM

So much thanx for nice guide. I am really sorry for so delayed response. out of jokes i do bg 1, it sends vim background :-)

I am sorry not to search LQ
Let alone google,
if friends like u give answers who goes for those?

rudeboy75 11-13-2008 04:41 AM

after session has been terminated
 
Hi,

One reason for me to start jobs in the background is that i want to disconnect from the server, while the jobs gets done.
But when i come back after having been disconnected, there is no mention of the background job when i type "jobs". (But using "top" i can see that my job is still running)
I can reproduce this on my local ubuntu machine:

## ----
$ vim test.txt &
[1] 9516
$ jobs
[1]+ Stopped vim test.txt

# Now i open another teminal.
$ jobs
$
## ----
I can only see the jobs in the first teminal window (bash).

Is there a way to see (my own) jobs from a different session?

can't find it using google and there doesn't seem to be a manpage for "jobs".

Thanx!

chrism01 11-13-2008 07:56 PM

It depends exactly what you are trying to do.
When you do

someprog &

it puts it into the background, BUT its still attached to the terminal/login session. If you try to completely logout it should warn you there are running jobs. If you continue to logout, that job should die, although it may possibly hang.
To disconnect the job when starting it, use nohup and '&'

nohup someprog &

from then old days meaning 'no-hangup'.

If its an interactive job you want to be able to re-connect to when you log back in, lookup the 'screen' utility.

See also http://rute.2038bug.com/node12.html....00000000000000

Geremia 01-03-2012 04:06 AM

Quote:

Originally Posted by rudeboy75 (Post 3340427)
Hi,

One reason for me to start jobs in the background is that i want to disconnect from the server, while the jobs gets done.
But when i come back after having been disconnected, there is no mention of the background job when i type "jobs". (But using "top" i can see that my job is still running)
I can reproduce this on my local ubuntu machine:

## ----
$ vim test.txt &
[1] 9516
$ jobs
[1]+ Stopped vim test.txt

# Now i open another teminal.
$ jobs
$
## ----
I can only see the jobs in the first teminal window (bash).

Is there a way to see (my own) jobs from a different session?

can't find it using google and there doesn't seem to be a manpage for "jobs".

Thanx!

I would like to know this, too. Has it been resolve here? Thanks

rudeboy75 01-09-2012 09:58 AM

yes there is, chrism01 gave the right answer.
I resolved this by installing "screen"
And then when i want to do something that takes too long to stay logged in, i use screen like this:

screen -DR
#the terminal turns blank, this is a new screen session.
Then I type the commands that i want executed which will take such a long time (only disadvantage is you can't scroll back up like normal - what is out of your screen is gone, you cannot scoll back up to it)
Then i just close the terminal window. It warns me "There is still a process running in this terminal. Closing the terminal will kill it.", but it won't, because i am using screen.

Then, when I log back in the next hour,day or week (before the next server reboot), i don't see the screen that i was working in. I first need to go back to my screen session with
screen -DR

my terminal now shows the commands that i typed in the screen session, and possibly the output if it is done.

HTH


All times are GMT -5. The time now is 11:02 PM.