[GLLUG] find / shell weirdness
Steve Parker
steve at steve-parker.org
Tue Oct 8 14:15:12 UTC 2013
stating the obvious, I'm sure you've tried this, but I'd start by checking for error output. Particularly, do you have spaces in $mydirs, and how are you coping with that?
I'd measure it like this:
find $mydirs -type f -a -cmin -10 -print > /tmp/filewatcher.count 2>/tmp/filewatcher.err
WC=`wc -l /tmp/filewatcher.count | awk ' { print $1 } ' `
if [ "$WC" -gt "0" ]; then
then
echo "`date`: Found $WC lines in filewatcher.count:"
we -l /tmp/filewatcher.count
cat -n /tmp/filewatcher.count
echo "Any errors?"
cat -n /tmp/filewatcher.err
echo "OK, Done. This should be enough info to start debugging the issue."
# email me notification bla bla bla
[ snip ]
fi
I assume you're running from cron so you'll pick up the stdout by email, otherwise redirect output to a file of course. This should get you enough info to pin down the problem very quickly
-----Original Message-----
From: "tid" <td at bloogaloo.co.uk>
Sent: Tuesday, October 8, 2013 10:30am
To: "The mailing list for the Greater London Linux User Group" <gllug at mailman.lug.org.uk>
Subject: [GLLUG] find / shell weirdness
Folks,
I have a small bash script which watches a number of folders for files
added in the last 10 minutes:
($mydirs below is just a list of ftp folders which clients upload to )
===================================================
find $mydirs -type f -a -cmin -10 -print > /tmp/filewatcher.count
if [ `wc -l /tmp/filewatcher.count | awk ' { print $1 } ' ` -gt 0 ]
then
# email me notification bla bla bla
[ snip ]
fi
====================================================
So, this has been working fine but recently it's started giving me a
lot of false positives - i.e the 'if' statement is firing, but no files are found - is there
some shell expansion going of which I'm unaware, or is it the more likely PBKAC?
Tid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20131008/bed0eaa2/attachment.html>
More information about the GLLUG
mailing list