Trying to setup user systemd service: Loaded: not-found (Reason: No such file or directory)

15,137

Solution 1

After creating or changing the unit file, you need to tell systemd to reload it:

systemctl --user daemon-reload

This explains why a reboot fixed it for @noraj.

Solution 2

I had the same problem; logging out and back in did not work but the answer was very simple: just reboot.

Share:
15,137

Related videos on Youtube

mxbi
Author by

mxbi

Updated on September 18, 2022

Comments

  • mxbi
    mxbi over 1 year

    I'm trying to make a user systemd service that runs a python script - however, when I try starting the service with systemctl --user start shadesmath, and then do systemctl status shadesmath, I get:

    ● shadesmath.service
       Loaded: not-found (Reason: No such file or directory)
       Active: inactive (dead)
    

    Here is the contents of my shadesmath.service file, which has been placed in ~/.config/systemd/user/shadesmath.service with permissions 744:

    [Unit]
    Description=ShadesMath
    AssertPathExists=/home/mikel/bots/mathbot/mathbot
    
    [Service]
    WorkingDirectory=/home/mikel/bots/mathbot/mathbot
    ExecStart=/home/mikel/anaconda3/bin/python bot.py parameters.json
    Restart=always
    
    [Install]
    WantedBy=default.target
    

    I tried running systemctl --user enable shadesmath, which created a symlink to the service in ~/.config/user/systemd/default.target.wants, but this hasn't seemed to change anything when I try starting the service.

    This is my first time trying to use systemd, so chances are I'm doing something stupid, but I can't figure out what the issue is. Any pointers on how to set this up would be much appreciated. My goal is to have a service that runs this python script, and to re-run it on startup/if the script finishes or crashes - ideally I want this to be a user service as I don't want this running as root.

    • mxbi
      mxbi about 6 years
      The issue seems to have fixed itself with some more fiddling (redoing the steps in the question) but unfortunately I don't know what actually ended up fixing it.