Wednesday, February 24, 2010

Monitoring File Changes on Linux 2

Referring to my previous post Monitoring File Changes on Linux, there is other alternative to do it

#! /bin/sh

# This is the log that will be monitored. 
# If any changes occur to this, then take appropriate action.

# We will need this log to see whether any changes occured to /tmp/goreb.log

# This is a 1-time command i.e. create the log file if it does nto exist.
[ ! -f $TEMP_LOG ] && touch -r $MONITORED_LOG $TEMP_LOG

[ $MONITORED_LOG -nt $TEMP_LOG ] && echo "$MONITORED_LOG is newer than $TEMP_LOG. Carry out your required operations"

# Update $TEMP_LOG with the new modified date of $MONITORED_LOG

No comments: