I haven't seen anybody here mention that you can do this with systemd path units [0],[1].
I know not everybody uses Linux (or loves systemd as much as I do) but it's a great solution if you already use systemd.
[0] https://www.redhat.com/sysadmin/introduction-path-units
[1] https://www.freedesktop.org/software/systemd/man/systemd.pat...