I created a script that will check for a directory update every 60 seconds and store it in a sleep.txt file until the directory stops being updated, at which point the script runs a bsub job. The problem with this is that I have to have a shell open running the check_directory.sh script so my computer must not sleep or turn off while this script is running. I was wondering if there is a way to do this in the background while I leave the computer? My current script is:
DIR_TO_CHECK='/dir/to/check'
OLD_CHECK='/home/sleep_file/sleep_file.txt'
if [ -e $OLD_CHECK ]
then
OLD_FILE=`cat $OLD_CHECK`
else
OLD_FILE="nothing"
fi
NEW_STAT=`stat -t $DIR_TO_CHECK`
if [ "$OLD_FILE" != "$NEW_STAT" ]
then
echo 'Directory is different.'
while true
do
echo "sleeping for a bit"
sleep 60
done
fi
bsub "...."
the bsub portion just submits my job when the first portion is done. Thanks and any help would be appreciated.