CompTIA Linux+ (XK0-006)TroubleshootingMedium

A system administrator is investigating why a critical service, `myapp.service`, fails to start after a system reboot. Upon checking `systemctl status myapp.service`, they see `ExecStart=/usr/local/bin/start_myapp.sh`. They then confirm that `/usr/local/bin/start_myapp.sh` exists and has execute permissions. Which of the following is the most appropriate next step to diagnose why the script itself might be failing when executed by systemd?

  1. ACheck `/var/log/messages` or `journalctl -xeu myapp.service` for detailed output from the script.
  2. BRun `systemctl restart myapp.service` to re-attempt the start.
  3. CVerify the ownership of `/usr/local/bin/start_myapp.sh` with `ls -l`.
  4. DEdit `/etc/systemd/system/myapp.service` to change `ExecStart` to `/bin/bash /usr/local/bin/start_myapp.sh`.
Show answer & explanation

Correct answer: A. Check `/var/log/messages` or `journalctl -xeu myapp.service` for detailed output from the script.

When a systemd service fails, the most crucial place to look for specific error messages from the `ExecStart` command is the systemd journal. `journalctl -xeu myapp.service` will show recent logs for that unit, including any output (stdout/stderr) from the script's execution.

Why the other options are wrong

  • B. Restarting the service without diagnosing the root cause is unlikely to fix the issue if the script itself is failing.
  • C. Ownership is less critical than execute permissions when the script is run by systemd; execute permissions are already confirmed.
  • D. While specifying the interpreter explicitly can sometimes help, it's a workaround. The first step should be to understand *why* it's failing, which requires checking logs.

systemd Service Troubleshooting

Troubleshooting systemd services involves checking their status, examining logs for execution errors, and verifying environment and dependencies.

  • `systemctl status <unit>` provides a high-level overview.
  • `journalctl -xeu <unit>` is critical for detailed log output from the service.
  • Common issues include incorrect paths, missing dependencies, permission problems, or environment variables.

Memory trick: When a service fails, 'J'ournal into it to 'J'ust get the 'J'ist.

More Troubleshooting questions