hi all,
needed some help writing a script (preferably in ksh) which :
1) detects if a file with ext '.kbs' has been changed. This file always sits in a particular dir.
2) if file has been changed then scp that file from one serverA to another serverB.
so far i have not done any code for this as i am stuck for ideas on how to start so any help would be appreciated.
thanks in advance.
the hints are
using ls -option u can check the last modified time.
you can use scp or ftp to transfer the file.
Check the man pages of these for more details
You could use something like this in a cron.
#! /bin/bash
HOLDLOC="/var/tmp/md5.last"
FILE=`find . -iname 'file.kbs'`
OLDMD5=`cat $HOLDLOC`
NEWMD5=`md5sum $FILE | cut -d " " -f 1`
if [ "$NEWMD5" = "$OLDMD5" ]; then
echo "Files haven't changed";
else
`scp $FILE user@host:/path`
echo "$NEWMD5" > "$HOLDLOC"
fi