Article 6F89N Systemd Path triggered service, only runs once, Config error or misunderstanding documentation?

Systemd Path triggered service, only runs once, Config error or misunderstanding documentation?

by
MickeJ
from LinuxQuestions.org on (#6F89N)
Hi all :)

I am using Systemd path unit to monitor a file and to run a service when the file is modified. This works as expected the first time, the path unit trigger on file modification and runs the service unit.

But the service only runs once, i expected the service to run again if the file was modified during the service runtime. (I am running services under --user and not system, does it matter?)

From the documentation...
https://www.freedesktop.org/software...temd.path.html
Quote:
When a service unit triggered by a path unit terminates (regardless whether it exited successfully or failed), monitored paths are checked immediately again, and the service accordingly restarted instantly.
So...
  1. file is modified
  2. systemd path unit notice and triggers the service
  3. service starts
  4. file is modified again while service is runnning
  5. service stops
  6. ...service is NOT restarted
I was expecting service to immediately start again based on that the file was changed again, this is how i understand the documentation. Am i misunderstanding documentation or?

Service unit file
Code:[Unit]
Description=Testing Hello World.
[Service]
Type=notify
ExecStart=/home/user/.local/bin/systemd_test.sh
NotifyAccess=all
[Install]
WantedBy=default.targetPath unit file
Code:[Unit]
Description=Monitor file for changes.
[Path]
PathModified=/home/user/.config/test.txt
[Install]
WantedBy=default.targetmy example test app that only runs once
Code:#!/usr/bin/env bash
set -eu
_main() {
systemd-notify --ready
sleep 20
}
_main "$@"
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments