Linux Labs

Packages, services, and logs / Stage 5 of 13

Systemd services: state and startup

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 6 · on a machine · 5 min

Why cron did not come up

What you will learn

  • Read the two states of a service — whether it runs now and whether it starts at boot.
  • Start and stop a service, and turn its autostart on and off.
  • Change one state of a service without touching the other.

The server was rebooted overnight as planned. In the morning it turned out that the scheduled jobs had not run: the cron scheduler did not start after boot. The on-call engineer started it by hand, and the jobs got going.

So that the night does not repeat itself, ask the machine what state cron is in.

Exercise · look

Three questions for the machine

Ask the machine three questions: is cron running now, will cron start at boot, and will ssh, the service people log in through, start at boot.

First, predict

This morning the on-call engineer started cron by hand. What will systemctl is-enabled cron print?

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 did the overnight reboot bring ssh up but not cron?

  • cron starts fine: the on-call engineer started it this morning, and systemctl is-active cron prints active.

  • cron failed to come up overnight, before the morning start. The start made cron run; the disabled from is-enabled explains the night.

  • nginx has nothing to do with logging in, yet it comes up at boot: systemctl is-enabled nginx prints enabled.

For ssh is-enabled prints enabled, for cron it prints disabled: the morning start switched the service on, while starting at boot stayed off.

Ubuntu 24.04
Loading…