2

Would like to get some help with systemd daemon service in Ubuntu. I have a python script I wrote to disable the touchscreen on a Dell XPS which is more of a problem than a useful feature. The script works but I don't want to have to launch it all the time which is why the idea came to my head to write a service file and have systemd launch it for me on startup.

The issue I run into is "(code=exited, status=1/FAILURE)". This is my first time and I did a little bit of research before I tried this however, I just can't figure it out at this point. Any ideas would be much appreciated.

This is the "systemctl status disable-ts.service output:

● disable-ts.service - Disable TouchScreen
  Loaded: loaded (/etc/systemd/system/disable-ts.service; enabled; vendor 
  preset: enabled)
  Active: failed (Result: exit-code) since Sat 2019-02-23 01:31:27 PST; 
  6min ago
  Process: 2667 ExecStart=/usr/bin/python disable-ts.py 
 (code=exited,status=1/FAILURE)

 Feb 23 01:31:27 roman-XPS-15-9560 systemd[1]: disable-ts.service: Service 
 hold-off time over, schedul
 Feb 23 01:31:27 roman-XPS-15-9560 systemd[1]: disable-ts.service: 
 Scheduled restart job, restart coun
 Feb 23 01:31:27 roman-XPS-15-9560 systemd[1]: Stopped Disable TouchScreen.
 Feb 23 01:31:27 roman-XPS-15-9560 systemd[1]: disable-ts.service: Start 
 request repeated too quickly.
 Feb 23 01:31:27 roman-XPS-15-9560 systemd[1]: disable-ts.service: Failed 
 with result 'exit-code'.
 Feb 23 01:31:27 roman-XPS-15-9560 systemd[1]: Failed to start Disable 
 TouchScreen.

This is the service file itself:

[Unit]
Description=Disable TouchScreen
After=multi-user.target

[Service]
User=roman
Type=forking
WorkingDirectory=/home/roman/Python-Scripts/
ExecStart=/usr/bin/python disable-ts.py
Restart=always

[Install]
WantedBy=multi-user.target

After I created this I did run:

sudo systemctl daemon-reload
sudo systemctl enable disable-ts.service
sudo systemctl start disable-ts.service
1

2 Answers 2

1

I also ran into the exact same problem today. I searched everywhere for a solution but nothing worked! I came across this question above and just like user Sean DiSanti above, I placed 'simple' in type and specified a workingdirectory. It worked!

Here is the full service file that fixed my problem.

[Unit]
Description=Upload Data
After=multi-user.target

[Service]
User=root
Type=simple
WorkingDirectory=/home/aws/webUpload/
ExecStart=/usr/bin/python3 upload_data.py

[Install]
WantedBy=multi-user.target
Sign up to request clarification or add additional context in comments.

Comments

0

Ran into this exact problem myself today, almost entirely the same setup except I was using 'simple' for type, and had not specified user or workingdirectory. Adding the working directory worked for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.