Linux Labs

Packages, services, and logs / Stage 6 of 13

Services under systemd

Not running Starting usually ~20 s
Leave the lesson

Step 4 of 7 · on a machine · 5 min

The main process

The systemctl status summary shows which process systemd treats as the service. This step covers what happens to it on restart and reload.

The Main PID line of the summary is the number of the service's main process, the one started from ExecStart. Below it, under CGroup, are all the processes of the service: for nginx, the main master process and a worker process. When the main process ends, the service is over as far as systemd is concerned; that is what happened at the start of the lesson.

restart stops the service and starts it again: a new main process replaces the old one, and the connections the service held are cut. Many services can reload — reread their settings without stopping — and nginx is one of them. See for yourself what this does to the nginx processes.

Exercise · look

Make nginx reread its settings

Look at the nginx processes in the status summary, ask nginx to reread its settings, and look at its processes once more with ps.

First, predict

What happens to the nginx main process after reload?

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

After reload the nginx main process is the same one: it reread the configuration and started a new worker, while the old worker finished the requests it had and exited. That is why a configuration change to a running nginx is applied with reload: the site is not interrupted. restart is for when the service has to be started over as a whole.

Ubuntu 24.04
Loading…