Linux Labs

Packages, services, and logs / Stage 6 of 13

Services under systemd

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 7 · on a machine · 4 min

Two services crash

What you will learn

  • Find a service's unit file and read in it which program systemd starts and whether it brings it back after a crash.
  • Read the journal of a single service and tell from it what happened to the service.
  • Tell restart from reload by the service's main process, and bring a crashed service back up.

Overnight the nginx web server crashed, and the site did not answer until morning. Repeat that crash on the training machine with two services, nginx and the cron scheduler, and compare what becomes of them.

Exercise · look

The same failure

pkill -KILL -x <name> kills the processes with that name abruptly, which is what a program crash looks like. Kill the cron and nginx processes this way, ask the machine whether both services are running, and look at the summary for cron.

First, predict

What will systemctl is-active cron nginx print after the two identical crashes? The first line is about cron, the second about nginx.

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

Why is cron running again after the same crash, while nginx is not?

  • It did: the Active line of the cron summary shows a start after your command, so a new process is running.

  • It can be started; you will do that at the end of the lesson. It just did not come back by itself: systemctl is-active printed failed for it.

  • A process killed with KILL ends at once and can do nothing more. Some other program started the new cron process.

After the crash systemd started cron again and left nginx in the failed state.

Ubuntu 24.04
Loading…