I made this script which checks to make sure that an offshore script is created. I works ok &emdash; I put in a function to make it a little cleaner. But I don't think that the function works because it keeps on printing out the same time, in seconds.
#!/bin/bash
#set -x
check_offshore ()
{
local RESULTS
RESULTS=$(ssh -q -T casper@mybox "ls -ltr /come/and/play/with/us/danny/DropBox| grep foreverr_and_$today.csv")
rc=$?
}
today=$(/bin/date +%Y%m%d)
time=$(/bin/date +"%T.%3N")
iterate=0
while [ $iterate -le 5 ]
do
check_offshore
if [[ $rc != 0 ]] ; then
echo "$time foreverr_and_$today.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox"
fi
sleep 5
iterate=$((iterate+1 ))
done
This is the log that it creates &emdash; the log time never changes. It stays the same, forever and ever and ever until the script stops.
17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
17:42:28.380 foreverr_and_20150102.csv is not present in casper@mybox:/come/and/play/with/us/danny/DropBox
What's up and how do I fix it?
time=$(...)inside the loop, how do you expect it to change?for ((iterate = 0; iterate <= 5; iterate++))to control the loop.