1

I've created a new service for a Python script that works when running standalone but gives errors below when run through systemd :

Oct 02 12:17:09 raspberrypi systemd[1]: Started Read pressure And Post to mqtt.
Oct 02 12:17:09 raspberrypi systemd[1]: ReadPressure.service: Main process exited, code=exited, status=203/EXEC
Oct 02 12:17:09 raspberrypi systemd[1]: ReadPressure.service: Unit entered failed state.
Oct 02 12:17:09 raspberrypi systemd[1]: ReadPressure.service: Failed with result 'exit-code'.
Oct 02 12:17:09 raspberrypi systemd[1]: ReadPressure.service: Service hold-off time over, scheduling restart.
Oct 02 12:17:09 raspberrypi systemd[1]: Stopped Read pressure And Post to mqtt.
Oct 02 12:17:09 raspberrypi systemd[1]: ReadPressure.service: Start request repeated too quickly.
Oct 02 12:17:09 raspberrypi systemd[1]: Failed to start Read pressure And Post to mqtt.
Oct 02 12:17:09 raspberrypi systemd[1]: ReadPressure.service: Unit entered failed state.
Oct 02 12:17:09 raspberrypi systemd[1]: ReadPressure.service: Failed with result 'exit-code'.

The service was created in "etc/systemd/system/ReadPressure.service. it has executable rights.

The services looks like :

[Unit]
Description=ReadPressure

[Service]
ExecStart=/bin/bash -c 'python3 -u /home/pi/ReadPressure/ReadPressure2AndPostToMqtt.py'
WorkingDirectory=/home/pi/ReadPressure/
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

Any ideas why im getting the errors? The operating system is Raspbian.

Thanks

  • A related question is unix.stackexchange.com/questions/458648 . – JdeBP Oct 3 '18 at 11:11
  • 1
    Why are you starting a bash that is calling python? You can start python directly with ExecStart=/usr/bin/python3... or wherever your python3 binary resides. – Thomas Oct 3 '18 at 11:18
  • Tried starting directly too. I saw a example like that so i tried it to see if it gives me different results. – resolver101 Oct 3 '18 at 11:37
  • according to hte docmentation "203 EXIT_EXEC" says "The actual process execution failed (specifically, the execve(2) system call). Most likely this is caused by a missing or non-accessible executable file." I guess it cant find the python file? in the log it says " Started Read pressure And Post to mqtt" but the file is named "ReadPressure2AndPostToMqtt.py". Do you think that could be part of the problem? i dont know how to correct it, any ideas? – resolver101 Oct 3 '18 at 11:39
  • What does type python3 return? – Thomas Oct 3 '18 at 12:10
1

Try

pi@raspberrypi:~ $ systemctl status ReadPressure.service

Paraphrasing @Ingo from https://raspberrypi.stackexchange.com/questions/92169/i-fail-to-start-a-python-program-in-thonny-on-startup

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

It could have these reasons:

  • wrong path to script (e.g. /home/py/ReadPressure2AndPostToMqtt.py)

  • script not executable

  • no shebang (first line)

  • wrong path in shebang (e.g. /bin/python3)

  • internal files in your script might be missing access permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.