# Created on savesnippets.com · https://savesnippets.com/Z48as6EK4OBGXw # Quick check (suitable for use in scripts) if systemctl is-active --quiet nginx; then echo "nginx is running" fi # Restart if down if ! systemctl is-active --quiet php8.3-fpm; then echo "php-fpm down, restarting…" systemctl restart php8.3-fpm fi # Detailed status systemctl status nginx --no-pager # Recent log lines from a unit journalctl -u nginx -n 50 --no-pager journalctl -u nginx --since "10 minutes ago" # Watch a service's logs in real time journalctl -u myapp -f