22
My custom service fails to start with systemctl. It just says "failed" without useful information. How can I debug this?
Loading...
Q&A · Answered
My custom service fails to start with systemctl. It just says "failed" without useful information. How can I debug this?
Accepted answer
Here's a comprehensive approach to debug systemd service failures:
# Get detailed status
sudo systemctl status yourservice.service -l
# View recent logs
sudo journalctl -u yourservice.service -n 50 --no-pager
# Follow logs in real-time
sudo journalctl -u yourservice.service -f
# Check your service file
cat /etc/systemd/system/yourservice.service
# Run the ExecStart command manually to see errors
/path/to/your/command
# Reload after editing service file
sudo systemctl daemon-reload
# Check permissions on executable
ls -la /path/to/your/command
# Check working directory exists
ls -la /path/to/working/dirSay what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.