incron is like cron but instead of time-based events, the events are based on file notifications.
sudo apt install incron
Add users to the /etc/incron.allow file who are allowed to use incron.
peter
NOTE: One user per line.
/etc/incron.deny can also be used to specifically prevent usage of incron by a user.
Edit the incron table:
incrontab -e
and populate with:
/etc/apache2/apache2.conf IN_MODIFY /usr/sbin/service apache2 stop /home/peter/some_dir_to_watch IN_MODIFY echo "$$ $@ $# $% $&"
NOTE: This monitors the directory for changes and will perform the echo passing along some parameters.
The format is very picky; use spaces, not tabs!
Parameters can include:
Events to monitor include:
IMPORTANT: incron is not capable of watching sub-directories.
Only files within the path will be monitored.
If sub-directories need to be monitored, they must be given their own entry.
incrontab -l