Updated:

systemd service checks

systemd manages services: Nginx, certbot timer, applications, workers, and background jobs.

When a service “does not work”, do not restart everything immediately. Check state, recent errors, and dependencies first.

Check service status

sudo systemctl status nginx --no-pager

Look for:

  • Active: active (running) — service is running;
  • Active: failed — service failed;
  • Loaded: — unit file was found;
  • recent log lines at the bottom.

Check all failed units

sudo systemctl --failed

Empty list is good.

If a failed unit appears, inspect it:

sudo systemctl status service-name --no-pager

Check whether service starts on boot

sudo systemctl is-enabled nginx

Possible answers:

AnswerMeaning
enabledstarts at boot
disableddoes not start automatically
staticnot enabled directly, may start through dependencies
maskedstartup is blocked

Start, stop, restart

sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx

Be careful with restart in production: it stops and starts the service.

Reload instead of restart

If a service supports reload, prefer it for config reloads:

sudo systemctl reload nginx

For Nginx:

sudo nginx -t
sudo systemctl reload nginx

If nginx -t fails, do not reload.

Read service logs

sudo journalctl -u nginx --no-pager -n 100

Follow logs:

sudo journalctl -u nginx -f

Last hour:

sudo journalctl -u nginx --since "1 hour ago" --no-pager

Check timers

For scheduled jobs:

sudo systemctl list-timers

For certbot:

sudo systemctl list-timers | grep certbot
sudo systemctl status certbot.timer --no-pager

If service does not start

Use this order:

sudo systemctl status service-name --no-pager
sudo journalctl -u service-name --no-pager -n 100
sudo systemctl cat service-name

Look for:

  • wrong binary path;
  • missing file permissions;
  • port already in use;
  • config error;
  • missing environment variable;
  • service exits immediately after start.

Check which port a service listens on

sudo ss -lntp | grep -E ':(80|443|7443)\b'

If a service should listen on a port but does not appear in ss, it did not start or is listening elsewhere.

Show unit file

sudo systemctl cat nginx

For custom overrides:

sudo systemctl cat service-name
sudo systemctl edit service-name

After changing unit files:

sudo systemctl daemon-reload
sudo systemctl restart service-name

Safe diagnostic order

sudo systemctl status service-name --no-pager
sudo journalctl -u service-name --no-pager -n 100
sudo systemctl --failed
sudo ss -lntp

Only after that decide: reload, restart, rollback, or config fix.

Common mistakes

Restarting without config test

Bad for Nginx:

sudo systemctl restart nginx

Better:

sudo nginx -t
sudo systemctl reload nginx

Ignoring failed units

If a service failed, systemctl --failed shows it faster than searching logs manually.

Checking the wrong service name

Find units:

systemctl list-units --type=service | grep -i nginx

Forgetting daemon-reload

After unit changes:

sudo systemctl daemon-reload

Otherwise systemd may still use the old unit definition.