when-changed
when-changed copied to clipboard
run as a service
easy method to run when-changed as a (systemd or other type of) service
You can simply create a .service file at /etc/systemd/system/ with the following content:
[Unit]
Description=My description
[Service]
Type=simple
ExecStart=/path/to/when-changed /path/to/watch "${COMMAND_TO_EXECUTE}"
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
In my use case I had to add restart because I am afraid OS can terminate my process after some time but I would not like to let it heppen.