I have written this script, however the output is not correct. It returns stat cannot stat no such file or directory. The file format is Living Room-20180418-0955588134.jpg
Any help will be appreciated.
#!/bin/sh
LASTFILE=$(cd /volume1/surveillance/@Snapshot && ls *.jpg | tail -1)
# Input file
# How many seconds before file is deemed "older"
OLDTIME=3600
# Get current and file times
CURTIME=$(date +%s)
FILETIME=$(stat "$LASTFILE" -c %Y)
TIMEDIFF=$(expr $CURTIME - $FILETIME)
# Check if file older
if [ $TIMEDIFF -gt $OLDTIME ]; then
echo "No Movement Dectected in Last Hour" ;
exit 1
fi
stat
in. Also don't parse the output fromls
. – Kusalananda Apr 18 '18 at 09:45