2

I have added a systemd service to monitor a path, but it is not working. I touched a .txt file under /tmp/test/, but it is not kicking in my service. I can't see "/tmp/testlog.txt" getting generated. Is there anything wrong in my service?

myservice.path

[Unit]
Description=Path Exists

[Path]
PathExistsGlob=/tmp/test/*.txt
PathChanged=/tmp/test/

[Install]
WantedBy=multi-user.target

myservice.service

[Unit]
Description=Test

[Service]
ExecStartPre=/bin/sh -c 'mkdir /tmp/test && sleep 60'
ExecStart=/bin/sh -c 'echo "Test Success" >> /tmp/testlog.txt & '

[Install]
WantedBy=multi-user.target

tmp dir:

# ls /tmp/test/
ab.txt
#

What could be the reason for the failure?

1

That was a timing issue. I added dependency and made this service to start as the very last one. That one solved the issue.

| improve this answer | |
  • Which dependency did you add? I'm facing a similar issue. – Marvin Feb 23 '18 at 0:57
  • I have a series of my own custom services. Added dependency using the keyword "After" and made this service running as the very last one. That solved my issue. – A R Mar 5 '18 at 20:20
0

I had this problem; try adding the following in the [Unit] section:

Wants=observer.service
| improve this answer | |

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.