bash:directories:monitor_a_directory_for_changes:using_incron
Differences
This shows you the differences between two versions of the page.
bash:directories:monitor_a_directory_for_changes:using_incron [2022/06/13 09:14] – created peter | bash:directories:monitor_a_directory_for_changes:using_incron [2022/06/13 09:18] (current) – peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== BASH - Directories - Monitor a directory for changes - Using incron ====== | ====== BASH - Directories - Monitor a directory for changes - Using incron ====== | ||
+ | |||
+ | **incron** is like cron but instead of time-based events, the events are based on file notifications. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Install incron ===== | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt install incron | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Change Permissions ===== | ||
+ | |||
+ | Add users to the **/ | ||
+ | |||
+ | <file bash / | ||
+ | peter | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | **/ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Monitor ===== | ||
+ | |||
+ | Edit the incron table: | ||
+ | |||
+ | <code bash> | ||
+ | incrontab -e | ||
+ | </ | ||
+ | |||
+ | and populate with: | ||
+ | |||
+ | < | ||
+ | / | ||
+ | |||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | The format is very picky; use spaces, not tabs! | ||
+ | |||
+ | * The format is **path mask command**. | ||
+ | |||
+ | Parameters can include: | ||
+ | |||
+ | * **$$**: | ||
+ | * **$@**: | ||
+ | * **$# | ||
+ | * **$%**: | ||
+ | * **$& | ||
+ | |||
+ | |||
+ | Events to monitor include: | ||
+ | |||
+ | * **IN_ACCESS**: | ||
+ | * **IN_ATTRIB**: | ||
+ | * **IN_CLOSE_WRITE**: | ||
+ | * **IN_CLOSE_NOWRITE**: | ||
+ | * **IN_CREATE**: | ||
+ | * **IN_DELETE**: | ||
+ | * **IN_DELETE_SELF**: | ||
+ | * **IN_MODIFY**: | ||
+ | * **IN_MOVE_SELF**: | ||
+ | * **IN_MOVED_FROM**: | ||
+ | * **IN_MOVED_TO**: | ||
+ | * **IN_OPEN**: | ||
+ | |||
+ | </ | ||
+ | |||
+ | <WRAP important> | ||
+ | **IMPORTANT: | ||
+ | |||
+ | Only files within the path will be monitored. | ||
+ | |||
+ | If sub-directories need to be monitored, they must be given their own entry. | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== List the incron table ===== | ||
+ | |||
+ | <code bash> | ||
+ | incrontab -l | ||
+ | </ | ||
bash/directories/monitor_a_directory_for_changes/using_incron.1655111674.txt.gz · Last modified: 2022/06/13 09:14 by peter