Skip to content
Justice Tech School

Processes and Jobs

command & runs in the background, jobs lists them, wait waits, kill sends a signal, $! is the last background pid and ps lists processes.

Example
sleep 0.2 & pid=$!
echo "started"
kill -0 $pid && echo "running"
wait $pid
echo "finished"
( sleep 0.1; echo bg done ) &
wait

Result

started
running
finished
bg done

Exercise

Run in the background.

sleep 5 

Quiz Test

What does wait do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.