I'm trying to use a systemd path + service to trigger a python script when a file changes.

I'm finding that the script is triggered on startup, independent of when I change the file.

Here's the snippet of my .path file:


currently while I'm testing, monitor.service simply triggers a script that writes to a log file with a timestamp. here's a snippet of the log file:

 14:26:40 Friday September 3, 2021 file modified

and when I do stat /home/pi/network/trigger.txt,

Access: 2021-07-14 17:07:42.871258883 -0400
Modify: 2021-08-24 16:53:00.879999930 -0400
Change: 2021-08-24 16:53:00.879999930 -0400

Clearly then, the file hasn't been modified, yet the .path unit triggers on startup regardless. What's going on here?

  • Just confirming: monitor.service doesn't have a [Install] WantedBy= does it? I've seen people make that mistake before: enabling the service which should only be triggered by a path/socket.
    – Stewart
    Sep 4, 2021 at 8:32
  • Yeah you're right, I had enabled the service. This solved the problem. Thanks!
    – sfraser
    Sep 8, 2021 at 0:47

1 Answer 1


The path shouldn't trigger monitor.service on boot, but it's a common mistake to have monitor.service itself enabled on boot.

If monitor.service contains the usual:


Then monitor.service will activate on boot OR whenever it gets triggers by your *.path.

Solution 1:

If this is a 3rd party service, then disable the service. That will prevent it from activating on boot, but will not prevent it from being triggered by your *.path:

sudo systemctl disable monitor.service

Solution 2:

If you wrote monitor.service yourself, then simply delete the [Install] section from monitor.service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.