systemd service doesn't start silently. How to debug?

Viewed 3418

I wrote a program (called whisky) which I now want to startup when booting the machine (a Raspberry Pi with which I'm creating an autonomous boat). So I created the file /lib/systemd/system/whisky.service:

[Unit]
Description=Whisky Boat Program
After=network.target
StartLimitIntervalSec=0

[Service]
ExecStart=/home/pi/whisky/run
KillMode=process
IgnoreSIGPIPE=true
Restart=always
RestartSec=3
User=root
Type=simple

[Install]
WantedBy=multi-user.target

I verified the file is correctly formatted for systemd using systemd-analyze verify whisky.service.

When I now run sudo systemctl start whisky I get no output (suggesting no errors).

sudo systemctl status whisky gives me the following output though:

* whisky.service - Whisky Boat Program
   Loaded: loaded (/lib/systemd/system/whisky.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Fri 2020-03-20 15:03:35 CET; 792ms ago
  Process: 8621 ExecStart=/home/pi/whisky/run (code=exited, status=203/EXEC)
 Main PID: 8621 (code=exited, status=203/EXEC)

Mar 20 15:03:35 raspberrypi systemd[1]: whisky.service: Unit entered failed state.
Mar 20 15:03:35 raspberrypi systemd[1]: whisky.service: Failed with result 'exit-code'.

The file /home/pi/whisky/run is actually a bash script which in turn starts the program. To check whether systemd even starts that bash script I added a first line to it: mkdir /home/pi/RUNNING_FROM_SYSTEMD. The dir RUNNING_FROM_SYSTEMD is not created though, so it seems systemd doesn't even try to run the file /home/pi/whisky/run.

Does anybody know what I'm doing wrong here?

1 Answers

Check your run script. There should be shebang. If not, add #!/bin/bash at the top of your script and give absolute path like ExecStart=/bin/bash /home/pi/whisky/run

The error message (code=exited, status=203/EXEC) is often seen when the script itself or its interpreter cannot be executed.

Other possible reasons maybe:

  • wrong path to script
  • script not executable
  • no shebang (first line) or wrong path in shebang
  • internal files in your script might be missing access permissions.
Related