The files are seperated by spaces. If they contain spaces or other special chars you need to quote them or mask the special characters. Both of these examples are equal:
With running the script as a service can be helpful if you administrate servers and habe developer teams with limited access. Instead of giving sudo permissions you can watch a touchfile to execute something specific as root, i.e. restart Apache httpd. In the real world this file would be touched during an automated deploy process.
Below is just an example service watching a dummy file in /tmp directory.
### Create the service file
In `/etc/systemd/system/` create a service config file **onfilechange-demo.service**
```txt
...
...
@@ -25,6 +26,13 @@ Type=simple
WantedBy=multi-user.target
```
**Remark**:
The example runs with root to restart a system service. Always limit the permission "User" an "Group" to that user that is needed for watching files and the command.
### Test
Check if the service exists `systemctl status onfilechange-demo`. If so you can start and stop it with `systemctl [start|stop] onfilechange-demo`
To start the service on reboot you additionally need to enable it: `systemctl enable onfilechange-demo`.
\ No newline at end of file
### Startup on boot
To start the service on reboot you additionally need to enable it: `systemctl enable onfilechange-demo`.