How can I resume a stopped job in Linux?












308















How can I resume a stopped job in Linux? I was using emacs and accidentally hit ctrl-z which blasted me back to the console. I can see it when I type 'jobs'



[*****]$ jobs
[1]+ Stopped emacs test_queue.cpp









share|improve this question















migrated from stackoverflow.com Apr 8 '11 at 10:42


This question came from our site for professional and enthusiast programmers.



















  • This is actually a fairly normal work flow for Vim, if you want to keep you commands in your bash history, then you hit Ctrl-z type your commands and then resume. Obviously you can run commands without leaving Vim via the :! ed command

    – icc97
    Jul 11 '18 at 2:32
















308















How can I resume a stopped job in Linux? I was using emacs and accidentally hit ctrl-z which blasted me back to the console. I can see it when I type 'jobs'



[*****]$ jobs
[1]+ Stopped emacs test_queue.cpp









share|improve this question















migrated from stackoverflow.com Apr 8 '11 at 10:42


This question came from our site for professional and enthusiast programmers.



















  • This is actually a fairly normal work flow for Vim, if you want to keep you commands in your bash history, then you hit Ctrl-z type your commands and then resume. Obviously you can run commands without leaving Vim via the :! ed command

    – icc97
    Jul 11 '18 at 2:32














308












308








308


98






How can I resume a stopped job in Linux? I was using emacs and accidentally hit ctrl-z which blasted me back to the console. I can see it when I type 'jobs'



[*****]$ jobs
[1]+ Stopped emacs test_queue.cpp









share|improve this question
















How can I resume a stopped job in Linux? I was using emacs and accidentally hit ctrl-z which blasted me back to the console. I can see it when I type 'jobs'



[*****]$ jobs
[1]+ Stopped emacs test_queue.cpp






linux sh job-control






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 5 '13 at 13:56









shgnInc

335316




335316










asked Apr 8 '11 at 9:38









BobbyBobby

1,6462106




1,6462106




migrated from stackoverflow.com Apr 8 '11 at 10:42


This question came from our site for professional and enthusiast programmers.









migrated from stackoverflow.com Apr 8 '11 at 10:42


This question came from our site for professional and enthusiast programmers.















  • This is actually a fairly normal work flow for Vim, if you want to keep you commands in your bash history, then you hit Ctrl-z type your commands and then resume. Obviously you can run commands without leaving Vim via the :! ed command

    – icc97
    Jul 11 '18 at 2:32



















  • This is actually a fairly normal work flow for Vim, if you want to keep you commands in your bash history, then you hit Ctrl-z type your commands and then resume. Obviously you can run commands without leaving Vim via the :! ed command

    – icc97
    Jul 11 '18 at 2:32

















This is actually a fairly normal work flow for Vim, if you want to keep you commands in your bash history, then you hit Ctrl-z type your commands and then resume. Obviously you can run commands without leaving Vim via the :! ed command

– icc97
Jul 11 '18 at 2:32





This is actually a fairly normal work flow for Vim, if you want to keep you commands in your bash history, then you hit Ctrl-z type your commands and then resume. Obviously you can run commands without leaving Vim via the :! ed command

– icc97
Jul 11 '18 at 2:32










5 Answers
5






active

oldest

votes


















344














The command fg is what you want to use. You can also give it a job number if there are more than one stopped jobs.






share|improve this answer



















  • 50





    for reference, fg is "foreground". You can also continue the job in the background with "bg".

    – Sirex
    Apr 8 '11 at 11:05



















238














The general job control commands in Linux are:





  • jobs - list the current jobs


  • fg - resume the job that's next in the queue


  • fg %[number] - resume job [number]


  • bg - Push the next job in the queue into the background


  • bg %[number] - Push the job [number] into the background


  • kill %[number] - Kill the job numbered [number]


  • kill -[signal] %[number] - Send the signal [signal] to job number [number]


  • disown %[number] - disown the process(no more terminal will be owner), so command will be alive even after closing the terminal.


That's pretty much all of them. Note the % infront of the job number in the commands - this is what tells kill you're talking about jobs and not processes.






share|improve this answer





















  • 27





    I avoid "kill %1" because mistyping it as "kill 1" is really really bad :)

    – barrycarter
    Apr 8 '11 at 14:05






  • 5





    @barrycarter That's very true. I usually do an fg and a Ctrl-C ;)

    – Majenko
    Apr 8 '11 at 14:08






  • 5





    @barry: Which is why init in Upstart ignores SIG{TERM,KILL} by default.

    – Hello71
    Apr 19 '11 at 2:26






  • 5





    And, of course, "never run as root" ;)

    – barrycarter
    Apr 19 '11 at 3:04



















45














You can also type %<process_name>; i.e., you hit Ctrl-Z in emacs, then you can type %emacs in the console and bring it back to the foreground.






share|improve this answer
























  • Very good to know

    – ZAD-Man
    Oct 22 '15 at 21:42



















29














Just to add to the other answers, bash lets you skip the fg if you specify a job number.



For example, these are equivalent and resume the latest job:



%
%%
fg
fg %


These resume job #4:



%4
fg 4





share|improve this answer



















  • 2





    While this is kind of cool, I still find it easier to type fg than %.

    – rr-
    Oct 10 '14 at 17:10






  • 3





    % is awesome, thanks! As a touch-typist, I find fg very irritating (same finger). But then, so is cd.

    – Gauthier
    Apr 15 '15 at 13:45











  • And you can start it in the background with either bg % or just % &.

    – Wildcard
    Aug 16 '16 at 18:43



















16














If you didn't launch it from current terminal, use ps aux | grep <process name> to find the process number (pid), then resume it with:



kill -SIGCONT <pid>





share|improve this answer



















  • 2





    This also works if you disown a stopped process

    – mabraham
    Dec 6 '17 at 1:21











  • can you also get access to its input/output as it happens when you say fg ?

    – Ciprian Tomoiagă
    Oct 2 '18 at 9:39










migrated from stackoverflow.com Apr 8 '11 at 10:42


This question came from our site for professional and enthusiast programmers.














5 Answers
5






active

oldest

votes








5 Answers
5






active

oldest

votes









active

oldest

votes






active

oldest

votes









344














The command fg is what you want to use. You can also give it a job number if there are more than one stopped jobs.






share|improve this answer



















  • 50





    for reference, fg is "foreground". You can also continue the job in the background with "bg".

    – Sirex
    Apr 8 '11 at 11:05
















344














The command fg is what you want to use. You can also give it a job number if there are more than one stopped jobs.






share|improve this answer



















  • 50





    for reference, fg is "foreground". You can also continue the job in the background with "bg".

    – Sirex
    Apr 8 '11 at 11:05














344












344








344







The command fg is what you want to use. You can also give it a job number if there are more than one stopped jobs.






share|improve this answer













The command fg is what you want to use. You can also give it a job number if there are more than one stopped jobs.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 8 '11 at 9:39









IlkkaIlkka

3,6461118




3,6461118








  • 50





    for reference, fg is "foreground". You can also continue the job in the background with "bg".

    – Sirex
    Apr 8 '11 at 11:05














  • 50





    for reference, fg is "foreground". You can also continue the job in the background with "bg".

    – Sirex
    Apr 8 '11 at 11:05








50




50





for reference, fg is "foreground". You can also continue the job in the background with "bg".

– Sirex
Apr 8 '11 at 11:05





for reference, fg is "foreground". You can also continue the job in the background with "bg".

– Sirex
Apr 8 '11 at 11:05













238














The general job control commands in Linux are:





  • jobs - list the current jobs


  • fg - resume the job that's next in the queue


  • fg %[number] - resume job [number]


  • bg - Push the next job in the queue into the background


  • bg %[number] - Push the job [number] into the background


  • kill %[number] - Kill the job numbered [number]


  • kill -[signal] %[number] - Send the signal [signal] to job number [number]


  • disown %[number] - disown the process(no more terminal will be owner), so command will be alive even after closing the terminal.


That's pretty much all of them. Note the % infront of the job number in the commands - this is what tells kill you're talking about jobs and not processes.






share|improve this answer





















  • 27





    I avoid "kill %1" because mistyping it as "kill 1" is really really bad :)

    – barrycarter
    Apr 8 '11 at 14:05






  • 5





    @barrycarter That's very true. I usually do an fg and a Ctrl-C ;)

    – Majenko
    Apr 8 '11 at 14:08






  • 5





    @barry: Which is why init in Upstart ignores SIG{TERM,KILL} by default.

    – Hello71
    Apr 19 '11 at 2:26






  • 5





    And, of course, "never run as root" ;)

    – barrycarter
    Apr 19 '11 at 3:04
















238














The general job control commands in Linux are:





  • jobs - list the current jobs


  • fg - resume the job that's next in the queue


  • fg %[number] - resume job [number]


  • bg - Push the next job in the queue into the background


  • bg %[number] - Push the job [number] into the background


  • kill %[number] - Kill the job numbered [number]


  • kill -[signal] %[number] - Send the signal [signal] to job number [number]


  • disown %[number] - disown the process(no more terminal will be owner), so command will be alive even after closing the terminal.


That's pretty much all of them. Note the % infront of the job number in the commands - this is what tells kill you're talking about jobs and not processes.






share|improve this answer





















  • 27





    I avoid "kill %1" because mistyping it as "kill 1" is really really bad :)

    – barrycarter
    Apr 8 '11 at 14:05






  • 5





    @barrycarter That's very true. I usually do an fg and a Ctrl-C ;)

    – Majenko
    Apr 8 '11 at 14:08






  • 5





    @barry: Which is why init in Upstart ignores SIG{TERM,KILL} by default.

    – Hello71
    Apr 19 '11 at 2:26






  • 5





    And, of course, "never run as root" ;)

    – barrycarter
    Apr 19 '11 at 3:04














238












238








238







The general job control commands in Linux are:





  • jobs - list the current jobs


  • fg - resume the job that's next in the queue


  • fg %[number] - resume job [number]


  • bg - Push the next job in the queue into the background


  • bg %[number] - Push the job [number] into the background


  • kill %[number] - Kill the job numbered [number]


  • kill -[signal] %[number] - Send the signal [signal] to job number [number]


  • disown %[number] - disown the process(no more terminal will be owner), so command will be alive even after closing the terminal.


That's pretty much all of them. Note the % infront of the job number in the commands - this is what tells kill you're talking about jobs and not processes.






share|improve this answer















The general job control commands in Linux are:





  • jobs - list the current jobs


  • fg - resume the job that's next in the queue


  • fg %[number] - resume job [number]


  • bg - Push the next job in the queue into the background


  • bg %[number] - Push the job [number] into the background


  • kill %[number] - Kill the job numbered [number]


  • kill -[signal] %[number] - Send the signal [signal] to job number [number]


  • disown %[number] - disown the process(no more terminal will be owner), so command will be alive even after closing the terminal.


That's pretty much all of them. Note the % infront of the job number in the commands - this is what tells kill you're talking about jobs and not processes.







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 16 '14 at 3:27









Thomas Hunter

4281615




4281615










answered Apr 8 '11 at 11:55









MajenkoMajenko

27.2k34472




27.2k34472








  • 27





    I avoid "kill %1" because mistyping it as "kill 1" is really really bad :)

    – barrycarter
    Apr 8 '11 at 14:05






  • 5





    @barrycarter That's very true. I usually do an fg and a Ctrl-C ;)

    – Majenko
    Apr 8 '11 at 14:08






  • 5





    @barry: Which is why init in Upstart ignores SIG{TERM,KILL} by default.

    – Hello71
    Apr 19 '11 at 2:26






  • 5





    And, of course, "never run as root" ;)

    – barrycarter
    Apr 19 '11 at 3:04














  • 27





    I avoid "kill %1" because mistyping it as "kill 1" is really really bad :)

    – barrycarter
    Apr 8 '11 at 14:05






  • 5





    @barrycarter That's very true. I usually do an fg and a Ctrl-C ;)

    – Majenko
    Apr 8 '11 at 14:08






  • 5





    @barry: Which is why init in Upstart ignores SIG{TERM,KILL} by default.

    – Hello71
    Apr 19 '11 at 2:26






  • 5





    And, of course, "never run as root" ;)

    – barrycarter
    Apr 19 '11 at 3:04








27




27





I avoid "kill %1" because mistyping it as "kill 1" is really really bad :)

– barrycarter
Apr 8 '11 at 14:05





I avoid "kill %1" because mistyping it as "kill 1" is really really bad :)

– barrycarter
Apr 8 '11 at 14:05




5




5





@barrycarter That's very true. I usually do an fg and a Ctrl-C ;)

– Majenko
Apr 8 '11 at 14:08





@barrycarter That's very true. I usually do an fg and a Ctrl-C ;)

– Majenko
Apr 8 '11 at 14:08




5




5





@barry: Which is why init in Upstart ignores SIG{TERM,KILL} by default.

– Hello71
Apr 19 '11 at 2:26





@barry: Which is why init in Upstart ignores SIG{TERM,KILL} by default.

– Hello71
Apr 19 '11 at 2:26




5




5





And, of course, "never run as root" ;)

– barrycarter
Apr 19 '11 at 3:04





And, of course, "never run as root" ;)

– barrycarter
Apr 19 '11 at 3:04











45














You can also type %<process_name>; i.e., you hit Ctrl-Z in emacs, then you can type %emacs in the console and bring it back to the foreground.






share|improve this answer
























  • Very good to know

    – ZAD-Man
    Oct 22 '15 at 21:42
















45














You can also type %<process_name>; i.e., you hit Ctrl-Z in emacs, then you can type %emacs in the console and bring it back to the foreground.






share|improve this answer
























  • Very good to know

    – ZAD-Man
    Oct 22 '15 at 21:42














45












45








45







You can also type %<process_name>; i.e., you hit Ctrl-Z in emacs, then you can type %emacs in the console and bring it back to the foreground.






share|improve this answer













You can also type %<process_name>; i.e., you hit Ctrl-Z in emacs, then you can type %emacs in the console and bring it back to the foreground.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 26 '13 at 21:04









NickDNickD

45142




45142













  • Very good to know

    – ZAD-Man
    Oct 22 '15 at 21:42



















  • Very good to know

    – ZAD-Man
    Oct 22 '15 at 21:42

















Very good to know

– ZAD-Man
Oct 22 '15 at 21:42





Very good to know

– ZAD-Man
Oct 22 '15 at 21:42











29














Just to add to the other answers, bash lets you skip the fg if you specify a job number.



For example, these are equivalent and resume the latest job:



%
%%
fg
fg %


These resume job #4:



%4
fg 4





share|improve this answer



















  • 2





    While this is kind of cool, I still find it easier to type fg than %.

    – rr-
    Oct 10 '14 at 17:10






  • 3





    % is awesome, thanks! As a touch-typist, I find fg very irritating (same finger). But then, so is cd.

    – Gauthier
    Apr 15 '15 at 13:45











  • And you can start it in the background with either bg % or just % &.

    – Wildcard
    Aug 16 '16 at 18:43
















29














Just to add to the other answers, bash lets you skip the fg if you specify a job number.



For example, these are equivalent and resume the latest job:



%
%%
fg
fg %


These resume job #4:



%4
fg 4





share|improve this answer



















  • 2





    While this is kind of cool, I still find it easier to type fg than %.

    – rr-
    Oct 10 '14 at 17:10






  • 3





    % is awesome, thanks! As a touch-typist, I find fg very irritating (same finger). But then, so is cd.

    – Gauthier
    Apr 15 '15 at 13:45











  • And you can start it in the background with either bg % or just % &.

    – Wildcard
    Aug 16 '16 at 18:43














29












29








29







Just to add to the other answers, bash lets you skip the fg if you specify a job number.



For example, these are equivalent and resume the latest job:



%
%%
fg
fg %


These resume job #4:



%4
fg 4





share|improve this answer













Just to add to the other answers, bash lets you skip the fg if you specify a job number.



For example, these are equivalent and resume the latest job:



%
%%
fg
fg %


These resume job #4:



%4
fg 4






share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 8 '11 at 14:03









grawitygrawity

236k37498553




236k37498553








  • 2





    While this is kind of cool, I still find it easier to type fg than %.

    – rr-
    Oct 10 '14 at 17:10






  • 3





    % is awesome, thanks! As a touch-typist, I find fg very irritating (same finger). But then, so is cd.

    – Gauthier
    Apr 15 '15 at 13:45











  • And you can start it in the background with either bg % or just % &.

    – Wildcard
    Aug 16 '16 at 18:43














  • 2





    While this is kind of cool, I still find it easier to type fg than %.

    – rr-
    Oct 10 '14 at 17:10






  • 3





    % is awesome, thanks! As a touch-typist, I find fg very irritating (same finger). But then, so is cd.

    – Gauthier
    Apr 15 '15 at 13:45











  • And you can start it in the background with either bg % or just % &.

    – Wildcard
    Aug 16 '16 at 18:43








2




2





While this is kind of cool, I still find it easier to type fg than %.

– rr-
Oct 10 '14 at 17:10





While this is kind of cool, I still find it easier to type fg than %.

– rr-
Oct 10 '14 at 17:10




3




3





% is awesome, thanks! As a touch-typist, I find fg very irritating (same finger). But then, so is cd.

– Gauthier
Apr 15 '15 at 13:45





% is awesome, thanks! As a touch-typist, I find fg very irritating (same finger). But then, so is cd.

– Gauthier
Apr 15 '15 at 13:45













And you can start it in the background with either bg % or just % &.

– Wildcard
Aug 16 '16 at 18:43





And you can start it in the background with either bg % or just % &.

– Wildcard
Aug 16 '16 at 18:43











16














If you didn't launch it from current terminal, use ps aux | grep <process name> to find the process number (pid), then resume it with:



kill -SIGCONT <pid>





share|improve this answer



















  • 2





    This also works if you disown a stopped process

    – mabraham
    Dec 6 '17 at 1:21











  • can you also get access to its input/output as it happens when you say fg ?

    – Ciprian Tomoiagă
    Oct 2 '18 at 9:39
















16














If you didn't launch it from current terminal, use ps aux | grep <process name> to find the process number (pid), then resume it with:



kill -SIGCONT <pid>





share|improve this answer



















  • 2





    This also works if you disown a stopped process

    – mabraham
    Dec 6 '17 at 1:21











  • can you also get access to its input/output as it happens when you say fg ?

    – Ciprian Tomoiagă
    Oct 2 '18 at 9:39














16












16








16







If you didn't launch it from current terminal, use ps aux | grep <process name> to find the process number (pid), then resume it with:



kill -SIGCONT <pid>





share|improve this answer













If you didn't launch it from current terminal, use ps aux | grep <process name> to find the process number (pid), then resume it with:



kill -SIGCONT <pid>






share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 4 '16 at 19:49









mahemoffmahemoff

4561514




4561514








  • 2





    This also works if you disown a stopped process

    – mabraham
    Dec 6 '17 at 1:21











  • can you also get access to its input/output as it happens when you say fg ?

    – Ciprian Tomoiagă
    Oct 2 '18 at 9:39














  • 2





    This also works if you disown a stopped process

    – mabraham
    Dec 6 '17 at 1:21











  • can you also get access to its input/output as it happens when you say fg ?

    – Ciprian Tomoiagă
    Oct 2 '18 at 9:39








2




2





This also works if you disown a stopped process

– mabraham
Dec 6 '17 at 1:21





This also works if you disown a stopped process

– mabraham
Dec 6 '17 at 1:21













can you also get access to its input/output as it happens when you say fg ?

– Ciprian Tomoiagă
Oct 2 '18 at 9:39





can you also get access to its input/output as it happens when you say fg ?

– Ciprian Tomoiagă
Oct 2 '18 at 9:39





migrated from stackoverflow.com Apr 8 '11 at 10:42


This question came from our site for professional and enthusiast programmers.



Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]