I am new to scripting, I made a script that reads 2 files and execute commands and as output a log file.
I want this script to run like a daemon and wait for changes in these 2 files to execute these commands again on theses files.
I am aware of using some inotify, but I don't know exactly how to use it and where to place the loop so the script will work as I want it too, that is:
- user executes the script for the first time
- this script reads these files and make the output log
- the script "sleeps" (daemonized) until these 2 log files change (some lines added to them)
- execute the same script again on these files
- sleep again and wait for changes in these 2 files
Best Answer
I had to monitor an old software, which does not have enough logging options. It is not exactly what you want, but might help you.
ref.cfg
andcur.cfg
) every secondcfg.log
if a diff is detectedwatch_cfg.sh
:Run those commands:
This detaches the process from the current session and sends it to the background.