LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-14-2013, 08:22 AM   #1
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Rep: Reputation: 30
Restart a stopped background job


A job was running in the background. I made to bring it foreground . Since I need to be back on prompt, i pressed ctrl+Z , which made the job to move to background , but STOPPED .

Is there a way to start it to "RUNNING" , from where it stopped? Or it can only be restarted?

[root@rhel6 ~]# jobs -l
[2]+ 6837 Running nohup ./testfore.sh &
[root@rhel6 ~]# fg 2
nohup ./testfore.sh
^Z
[2]+ Stopped nohup ./testfore.sh
[root@rhel6 ~]# jobs -l
[2]+ 6837 Stopped nohup ./testfore.sh
 
Old 07-14-2013, 01:27 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Type "bg" to BackGround the job
 
Old 07-15-2013, 02:40 AM   #3
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Original Poster
Rep: Reputation: 30
Thanks .Yes , When "Ctrl+Z" is pressed , it will move to background . I need to know how to start the stopped Job which is Running(stopped) is background.

[root@rhel6 ~]# jobs -l
[2]+ 6837 Stopped nohup ./testfore.sh
 
Old 07-15-2013, 05:32 AM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Ctrl+z suspends that last ( i.e. current ) job
http://en.wikipedia.org/wiki/Ctrl-Z

so you should take AlucardZero's advice and type bg to resume it in the background
 
Old 07-15-2013, 05:39 AM   #5
Pastychomper
Member
 
Registered: Sep 2011
Location: Scotland
Distribution: Slackware, Devuan, Android
Posts: 132

Rep: Reputation: 243Reputation: 243Reputation: 243
I think you're looking for fg.

As you've mentioned, ctrl+Z stops the job, so it's still in memory but not running. bg will make it resume running in the background, or fg will bring it back to the foreground.
 
1 members found this post helpful.
Old 07-15-2013, 06:48 AM   #6
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Ahh, thanks Pastychomper, I think I just got confused and read *is* background, as *as* background assuming typo
 
Old 07-15-2013, 04:27 PM   #7
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Original Poster
Rep: Reputation: 30
Thanks for all . Here is my tries...
Code:
[root@rhel6 ~]# jobs
[1]+  Running                 nohup ./testfore.sh &
[root@rhel6 ~]# fg 1
nohup ./testfore.sh
^Z
[1]+  Stopped                 nohup ./testfore.sh
[root@rhel6 ~]# jobs -l
[1]+  1702 Stopped                 nohup ./testfore.sh
[root@rhel6 ~]# bg
[1]+ nohup ./testfore.sh &
[root@rhel6 ~]# jobs -l
[1]+  1702 Running                 nohup ./testfore.sh &
[root@rhel6 ~]# fg
nohup ./testfore.sh
^Z
[1]+  Stopped                 nohup ./testfore.sh
[root@rhel6 ~]# bg
[1]+ nohup ./testfore.sh &
[root@rhel6 ~]# jobs -l
[1]+  1702 Running                 nohup ./testfore.sh &
[root@rhel6 ~]#
Sorry AlucardZero for replying without trying the "bg" . I thought it will simply move a job to background, not make it run . But it does ...

Thanks again to all.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
to restart a job mrinal_das Linux - Newbie 1 03-10-2011 01:32 PM
How to process a job in background? k_oudom Linux - Networking 20 02-21-2010 10:26 AM
Background job won't stay in the background! JMJ_coder Linux - General 1 03-17-2008 06:05 PM
how to stop background job jax8 Linux - Newbie 6 02-17-2004 12:59 AM
Help! stopped job! IamLinuxNewbie Linux - General 3 02-25-2003 08:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration