[nmglug] cron e-mail /dev/null

Ed Santiago nmglug at edsantiago.com
Mon Jan 25 05:40:39 PST 2010


On Mon, 25 Jan 2010 05:52:01 -0700, a wrote:
>When there is "*.jpg" content the cronjob successfully reads:
>"/home/kaluta/kaluta.us/jerry-camera/*.jpg".
>
>When there is not "*.jpg" content (i.e. camera off). I am e-mailed the
>following message hourly by cron:
>"/usr/bin/find: /home/kaluta/kaluta.us/jerry-camera/*.jpg: No such file"
>or directory.
>
>Can anyone suggest a method of avoiding the "superfluous" hourly e-mail.
>tnx, Anthony 

 * Snip at cut-here.
 * Save into a file named "camera-clean" (or whatever you like),
   in a bin directory of your choosing.
 * Make it executable [ chmod 755 /my/bin/camera-clean ]
 * Put it into source control (git, hg, even RCS).
 * Fix the FIXMEs (you'll thank yourself later).
 * Change your cron rule to:

   - ...* * [complex find command]
   + ...* * /my/bin/camera-clean

Writing a short script may seem like overkill.  It's not.
Complex cron entries are unmaintainable.  

Hope this helps,
Ed

---------------cut--here--------------------------------------------
#!/bin/sh
#
# camera-clean - clean up blah blah blah FIXME
#
# $Id$
#

# Directory containing images.  jpg files are deposited here by FIXME.
cd /home/kaluta/kaluta.us/jerry-camera || exit 1

# Look for jpg files older than 1 day, and silently delete them.
# Only look in current directory (-maxdepth), not in subdirectories.
find . -maxdepth 1 -name '*.jpg' -mtime +1 -print0 | \
     xargs -0 --no-run-if-empty rm -f



More information about the nmglug mailing list