Quantcast
Channel: Active questions tagged 22.04 - Ask Ubuntu
Viewing all articles
Browse latest Browse all 4421

systemd service fails to start script in home directory

$
0
0

I would like to start a python script (i.e. a Flask server) at boot of Ubuntu 22.04. I have created a file /lib/systemd/system/myService.service with following content:

[Unit]Description=The service starts a Flask server[Service]User=myUsernameExecStart=/home/myUsername/PycharmProjects/myProject/server/server.sh[Install]WantedBy=multi-user.target

server.sh contains the following content:

#!/bin/basheval "$(conda shell.bash hook)"conda activate huggingfacepython server.py

When I start the service, I'm getting the following error:

Mar 28 02:04:39 myComputer systemd[1]: Started myService.Mar 28 02:04:39 myComputer  systemd[1713428]: myService.service: Failed to locate executable /home/myUsername/PycharmProjects/myProject/server/server.sh: Permission deniedMar 28 02:04:39 myComputer  systemd[1713428]: myService.service: Failed at step EXEC spawning /home/myUsername/PycharmProjects/myProject/server/server.sh: Permission deniedMar 28 02:04:39 myComputer  systemd[1]: myService.service: Main process exited, code=exited, status=203/EXECMar 28 02:04:39 myComputer  systemd[1]: myService.service: Failed with result 'exit-code'.

When I directly execute server.sh it works, so the problem is the service. I think that the problem could be that I want to start the script in my home directory.

Is there a possibility to get the service to start the server.sh in my home directory? I don't want to move it outside of my home because other users have access to the computer and they should not have access to the files.


Viewing all articles
Browse latest Browse all 4421

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>