systemd guide services timers logs banner
Linux service management

systemd Guide: Services, Timers, Logs and Troubleshooting

systemd is the service manager used by many modern Linux distributions. If you manage servers, you will use it to start services, enable services at boot, inspect logs, create timers and diagnose failures.

On this page
Overview

What is systemd?

systemd is an init and service management system. It starts the system, manages services, tracks dependencies, captures logs through the journal, and can run scheduled tasks through timers.

Services

Manage daemons like nginx, sshd, mariadb and custom scripts.

Timers

Schedule tasks like backups, cleanup scripts and health checks.

Logs

Use journalctl to inspect logs for services and boot sessions.

Commands

systemctl basics

TaskCommand
Check service statussystemctl status nginx
Start a servicesudo systemctl start nginx
Stop a servicesudo systemctl stop nginx
Restart a servicesudo systemctl restart nginx
Reload configsudo systemctl reload nginx
Enable at bootsudo systemctl enable nginx
Show failed unitssystemctl --failed
$ systemctl status nginx
● nginx.service - A high performance web server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
     Active: active (running) since Sun 2026-05-03 10:22:41 BST; 2h ago
   Main PID: 1184 (nginx)
      Tasks: 3
     Memory: 12.4M
Common confusion

systemctl enable vs start

start runs the service now. enable configures it to start on boot. If you want both, use enable --now.

sudo systemctl enable --now nginx
$ systemctl is-enabled nginx
enabled
Logs

journalctl examples

TaskCommand
Logs for one servicejournalctl -u nginx
Latest 50 linesjournalctl -u nginx -n 50
Follow live logsjournalctl -u nginx -f
Logs since todayjournalctl --since today
Logs from current bootjournalctl -b
Kernel messagesjournalctl -k
$ journalctl -u sshd -n 5 --no-pager
May 03 12:20:12 server sshd[2410]: Accepted publickey for admin from 203.0.113.10 port 51122
May 03 12:20:12 server sshd[2410]: pam_unix(sshd:session): session opened for user admin
May 03 12:41:03 server sshd[2511]: Failed password for invalid user test from 198.51.100.22
Unit files

Basic systemd service unit

Custom services are commonly stored in /etc/systemd/system/. Here is a simple oneshot unit that runs a script.

[Unit]
Description=Run website backup
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/website-backup.sh

[Install]
WantedBy=multi-user.target

After creating or editing a unit file, reload systemd:

sudo systemctl daemon-reload
Timers

systemd timers instead of cron

Timers can replace many cron jobs. They are easy to inspect with systemctl list-timers and they integrate with the journal.

[Unit]
Description=Run backup daily

[Timer]
OnCalendar=*-*-* 02:30:00
Persistent=true
Unit=website-backup.service

[Install]
WantedBy=timers.target
sudo systemctl enable --now website-backup.timer
systemctl list-timers website-backup.timer
Troubleshooting

How to troubleshoot a failed service

  1. Check status: systemctl status service-name
  2. Read logs: journalctl -u service-name -n 100 --no-pager
  3. Check failed units: systemctl --failed
  4. Validate the service config, if the application has a config test command.
  5. Reload systemd after editing unit files: systemctl daemon-reload
  6. Restart the service and watch logs live.
$ systemctl --failed
UNIT              LOAD   ACTIVE SUB    DESCRIPTION
backup.service    loaded failed failed Backup example.com website with rsync

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state.
Practical examples

Useful systemd examples

Reload a service after a config change

sudo nginx -t
sudo systemctl reload nginx

Restart and follow logs

sudo systemctl restart nginx
sudo journalctl -u nginx -f

Show unit file location

systemctl cat nginx

Check boot time blame

systemd-analyze blame
Related

More Linux admin practice

Troubleshooting flow

A practical systemd troubleshooting order

When a service fails, check status first, then logs, then the unit file. This keeps the investigation clean and avoids changing things blindly.

# 1. Check current state
systemctl status nginx

# 2. Read recent service logs
journalctl -u nginx -n 80 --no-pager

# 3. Follow logs live while restarting
journalctl -u nginx -f

# 4. Check the unit file
systemctl cat nginx

# 5. Reload systemd after editing a unit
systemctl daemon-reload
Example failure clues:
Active: failed (Result: exit-code)
Main PID: 1842 (code=exited, status=1/FAILURE)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Quick reference

start vs enable vs reload

CommandMeaning
systemctl start nginxStart the service now.
systemctl enable nginxStart the service automatically at boot.
systemctl restart nginxStop and start the service.
systemctl reload nginxReload configuration without a full restart, if supported.
systemctl daemon-reloadReload unit files after editing systemd configuration.
FAQ

Frequently Asked Questions

What is the difference between systemctl start and enable?

start runs a service now. enable configures it to start automatically at boot.

When should I run systemctl daemon-reload?

Run daemon-reload after creating or editing a unit file so systemd reloads the unit definition.

How do I view logs for one service?

Use journalctl -u service-name, for example journalctl -u nginx -n 100 --no-pager.

Why does systemctl show active but the site is still down?

The service may be running but misconfigured, listening on the wrong port, blocked by firewall rules or failing at the application layer.

$ practise_next --topic systemd

Practise this next

Turn the guide into practice with a related quiz, builder, cheat sheet or learning path.