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.
|
use "jobs" it lists all backgrounded processes.
then "fg [number]" eg: Code:
$jobs |
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? |
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! |
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 |
Quote:
|
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. |