-3

I have added 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 cant 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?

A R
  • 2,697
  • 3
  • 21
  • 38
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Jun 22 '17 at 19:03
  • If systemd is an off topic, why do you have systemd as a tag? – A R Jun 22 '17 at 19:42

1 Answers1

0

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

A R
  • 2,697
  • 3
  • 21
  • 38