Hi,
I need to run a script whenever the Cron file is modified.
The requirement is whenever a user modifies the cron file, the script should run automatically.
Can you please provide your inputs ?
Hi,
I need to run a script whenever the Cron file is modified.
The requirement is whenever a user modifies the cron file, the script should run automatically.
Can you please provide your inputs ?
If you stored the sum value of the output from crontab -l somewhere then you could run a conjob to compare the actual sum value from crontab -l with the stored one and run something if they were different.
Manual setup:
# crontab -l | sum > /root/crontab-l.sum
Script to run from root cron:
LIVECRONSUM=`crontab -l | sum`
STOREDCRONSUM=`cat /root/crontab-l.sum`
if [ ${LIVECRONSUM} -ne ${STOREDCRONSUM} ]; then
#run something
logger -p daemon.notice "The root user crontab has changed!"
# updated stored value so that the above only runs once
crontab -l | sum > /root/crontab-l.sum
fi
Thanks a lot.
What i want is that whenever user modifies the cron file, the script should run automatically and no manual intervention is needed to run the script.
The script will then find the differences between the old and new cron file.
isn't the above logic what you're looking for?
Will the above process automaticall invoke the process if someone modifies the cron ?
I want the script to be executed automatically and not to be run by the user.
The intention is to run it from cron, so that means it will run as frequently as you want it to but will only alert you if and when a change is seen.