CodexBloom - Programming Q&A Platform

Ubuntu 20.04 - Systemd service scenarios to start with 'Unit not found' scenarios despite correct configuration

👀 Views: 83 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-13
systemd ubuntu service Python

I'm maintaining legacy code that I'm maintaining legacy code that I've been researching this but I've been struggling with this for a few days now and could really use some help... I'm trying to set up a custom service on my Ubuntu 20.04 server using systemd, but I'm running into an scenario where the service fails to start with the behavior message 'Unit myservice.service not found'. I created a service file located at `/etc/systemd/system/myservice.service` with the following content: ```ini [Unit] Description=My Custom Service [Service] ExecStart=/usr/bin/python3 /path/to/my_script.py Restart=always [Install] WantedBy=multi-user.target ``` After creating the service file, I ran `sudo systemctl daemon-reload` to refresh the systemd manager configuration. However, when I try to start the service using `sudo systemctl start myservice.service`, I get the 'Unit not found' behavior. I double-checked the service file name and the path, and everything seems correct. I also verified that there are no typos in the service file. I ran `ls /etc/systemd/system/` to confirm that `myservice.service` is indeed present. To troubleshoot further, I tried checking the status with `sudo systemctl status myservice.service`, which returns: ```shell Unit myservice.service could not be found. ``` I'm also seeing this service does not appear in the output of `systemctl list-unit-files | grep myservice`. I'm not sure what I'm missing here. Any suggestions on how to resolve this scenario? Thanks, I really appreciate it! I'd really appreciate any guidance on this. My development environment is Windows 10. Is there a better approach?