Skip to main content

Service Monitoring

Most production workloads run as systemd services. When something is broken, the fastest reliable signal is often service state plus recent logs.

Quick Summary
  • Use systemctl status and journalctl -u as your default pair.
  • Watch restart loops and dependency failures.
  • Prefer service restarts over killing random PIDs.

Identify important services

On a typical WordPress VPS you care about:

  • Web server: nginx, apache2, or openlitespeed.
  • PHP runtime: php-fpm.
  • Database: mysql or mariadb.
  • Optional: redis-server, memcached.

List active services:

list-active-services.sh
systemctl list-units --type=service --state=running --no-pager

Check service state

service-status-check.sh
sudo systemctl --no-pager --full status nginx || true
sudo systemctl is-active nginx || true
sudo systemctl is-failed nginx || true

Read logs for a service

service-logs.sh
sudo journalctl -u nginx --since '1 hour ago' --no-pager | tail -n 200
sudo journalctl -u php8.2-fpm --since '1 hour ago' --no-pager | tail -n 200
sudo journalctl -u mysql --since '1 hour ago' --no-pager | tail -n 200

Restart policies and restart loops

If a service is restarting repeatedly, check recent events:

service-restart-loop-check.sh
systemctl show nginx -p NRestarts -p Restart -p RestartUSec
journalctl -u nginx --since '30 minutes ago' --no-pager | rg -n 'fail|error|exit|signal'
warning

Repeated restarts can amplify load (crash loops). If needed, stop the service to stabilize the box and investigate calmly.

stop-service-to-stabilize.sh
sudo systemctl stop nginx
sudo systemctl status nginx --no-pager --full || true

Next steps

  • For host-level health signals: see [Monitoring health](./monitoring-health).
  • For process-level intervention: see [Process control](./process-control).