Linux Labs

Users, permissions, and processes / Stage 11 of 13

Background jobs and the terminal

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 7 · on a machine · 5 min

You need the terminal for something else

What you will learn

  • Run a long command in the background and find it in the job list.
  • Pause a job, continue it in the background, and bring it back to the terminal.
  • Tell a job number from a PID and wait for a background command to finish.

A report export takes ten minutes, and meanwhile you need the terminal for other work. Start a long command and see how the shell responds.

Exercise · look

A long command and the prompt

Run the three commands in order. sleep 600 does nothing for ten minutes and stands in for a long export, and the & at the end of the line is the new thing to watch.

First, predict

When will the prompt come back after sleep 600 &?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

The prompt is back. What is going on with sleep 600 now?

  • Ten minutes have not passed yet: jobs shows Running sleep 600 &, and ps shows a sleep 600 row.

  • The command has already started: ps shows a sleep 600 process with the PID the shell printed after [1].

  • jobs would show a pause as Stopped. For sleep 600 it shows Running.

sleep 600 is running: jobs shows it as Running, and ps as a process with the same PID.

Ubuntu 24.04
Loading…