Running Python code on startup using systemd. Code does start at boot up but stops and service ends

I have a Python code on NVIDIA Jetson TX@ (running Ubuntu 18.04) that records videos upon receiving commands (via serial communication with another hardware). The recording is done by the IP camera connected to the Ethernet Port of NVIDIA Jetson TX2. The video files are saved at the same path where the Python code is.

I would like to have the python code run on startup as soon as the board is booted.

The code stops running after the first serial command is sent. So if I want to send another command, it won’t work because the code isn’t running anymore upon checking ps -ax|grep python3. However, when I first boot Jetson, the process does show running. It just stops after the first serial communication.

My code is in /usr/bin/ .

Here is the systemd service configuration. I have named my service dummy.service:

> GNU nano 2.9.3                                                     /lib/systemd/system/dummy.service                                                                
Description=Dummy Service

ExecStart=/usr/bin/python3 /usr/bin/


If I check the status of the service after the code has stopped on it’s own after the first camera operation command, I get this:

sudo systemctl status dummy.service

● dummy.service - Dummy Service

   Loaded: loaded (/lib/systemd/system/dummy.service; enabled; vendor preset: enabled)

   Active: failed (Result: exit-code) since Thu 2020-11-12 19:42:44 IST; 22s ago

  Process: 7337 ExecStart=/usr/bin/python3 /usr/bin/ (code=exited, status=1/FAILURE)

 Main PID: 7337 (code=exited, status=1/FAILURE)

Nov 12 19:41:57 jetson-desktop systemd[1]: Started Dummy Service.

Nov 12 19:42:44 jetson-desktop systemd[1]: dummy.service: Main process exited, code=exited, status=1/FAILURE

Nov 12 19:42:44 jetson-desktop systemd[1]: dummy.service: Failed with result 'exit-code'.

Any insights? I’m not sure what I’m doing wrong.


Duplicate with:
(although this is centered more on using systemd, so this is probably the better URL to use…just don’t use two for the same thing)

I don’t have this to set up and try, but I see this as a conflict:

This is saying wants this, and that this is not allowed until is reached. You cannot both require this for and make this available until after

You should also be very careful to find out if your software will run with no X/GUI session. Python would not have an issue with this, but some camera software must have an X context.