If I ssh to a box and start a task that will take some time to complete I usually press control+z to pause the process, and then immediately type bg 1 to put run it in the background.

I can then type jobs and see it running.

If I disconnect (type exit, press control+d, etc) and then log back in, I can no longer type jobs to see it running - it won't show anything.

I know I can type something like

ps -u `whoami`

to see what items are running, but I'm not sure if I can pause them any longer. I know I can kill them, but is there a way to pause them or can I somehow get them to show back up in the jobs list?

Linux-fu tips regarding jobs and process management are also welcome and will be upvoted.

  • 1
    Run a tmux session on the remote box... It makes <strike>job control</strike> everything easier. – jasonwryan Jan 22 '12 at 7:46
  • 1
    Run all long-timed processes inside Screen or Tmux. If you've already started a process outside one of these, see How can I disown it a running process and associate it to a new screen shell? but that doesn't always work (sometimes it'll crash your program), so it's best to plan ahead. Systematically using Screen or Tmux on remote connections is a good habit to get into. – Gilles 'SO- stop being evil' Jan 23 '12 at 0:01
  • thank you both. i've never heard of those but i will be trying to get started with them this week. I'm going to google for tutorials and read the man pages unless you guys have some specific links that would be helpful for a Screen/Tmux noob. guess these would be better than just having multiple tabs in the terminal program :) – cwd Jan 23 '12 at 0:15

You can use kill -STOP pid to pause a job and kill -CONT pid to resume it. You get the proper pid from the ps command you already know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.