SUMMARY cron jobs

From: hydres!paul@uunet.UUCP
Date: Wed Jan 22 1992 - 17:28:52 CST

My original query was getting rid of messages from this crin job.

>15 3 * * * find / -name .nfs\* -mtime +7 -exec rm -f {} \; ---
>----o -fstype nfs -prune
>I have tried in vain sending the error messages generated by this
>cron job to /dev/null with no success.
Here is the replies...

Hmmm, cron is using /bin/sh, not csh, right? Try:
15 3 * * * find / -name .nfs\* -mtime +7 -exec rm -f {} \; -o -fstype nfs -prune > /dev/null 2>&1

The bit of gibberish at the end is telling sh to redirect stderr (2) as well as
stdout (1). Alternatively, you could pipe the output through 'grep -v' to
filter out the known bogus messages and leave any other failures alone...

Jay Lessert {decwrl,,sun,verdix}!bit!jayl
Bipolar Integrated Technology, Inc.
503-629-5490 (fax)503-690-1498

This works for us:

15 3 * * * /usr/bin/find / -name .nfs\* -mtime +7 -exec /bin/rm -f {} \;
     -o -fstype nfs -prune 2>&1 | /usr/bin/egrep -v 'No such file or directory'

This also deals with /tmp files that get deleted just as find is
looking at them -- which we don't care about anyway.

( Who is Melissa ? )

Remember that cron feeds the line to sh, so you'll need

>/dev/null 2&>1

to redirect the find output.

Anon ??

Ah yes, the infamous "Search every mounted partition on this
machine" default crontab entry. Even if the machines are up,
you should note that this command does a find down the tree
for the mounted partition from every machine which mounts it.
Very amusing - we're an observatory, and some people work at
night, so when 35 machines all start polling the same nfs-mounted
directory ....

I got around it by writing my own modified "find" script and running
that from cron. The crontab entry is simply
15 3 * * * /local/bin/SWN.find >/dev/null
and the script, easily modified to your own purposes, is attached.
You may want to prune some of the comments before spreading it around!
(This runs on our Scientists' Workstation Network, hence the SWN.)

Good luck.
------------------cut here------------------
# A modified find for use in crontab - this will be run on all the SWN
# once their crontab entries are updated, instead of the default "find"
# command, so please change this file only with caution.
# Nigel Sharp, Feb.1991
# Don't search through read-only, nfs or swap file systems.
# The SEARCH path excludes such things as listed in the fstab, and find
# doesn't follow symbolic links itself, so the only remaining problem
# is the auto-mounter, and the prune on "tmp_mnt" takes care of that.
# This shell script works with the network unplugged, so I must have got
# something right (at last !).
# Default entry as supplied does the ".nfs*" thing, so leave it in.
# Remove core files (nobody knows what to do with them, especially not SWN).
set SEARCH=`awk '{ if (($3 ~ /^4\.2$/) && ($4 ~ /^rw/)) {print $2} }' /etc/fstab`
#echo $SEARCH
find $SEARCH -xdev \
    -name "*tmp_mnt*" -prune -o \
    '(' -name ".nfs*" -mtime +7 ')' -print -o \
    -name core -exec rm -f {} \; \

One thing that you could do, is something like this:

15 3 * * * find / -name .nfs\* -mtime +7 -exec rm -f {} \; > /dev/null 2>&1

This will cause stdout and stderr to be ignored.

Best of luck,

Jeff Beadles

thanks to all who replied I am trying the redirectiopn solution provided in this summary, others may be interested in the other replies. thanks again !!

"I want to buy a husband who, every week when I sit down to watch `St. Elsewhere', won't scream, `FORGET IT, BLANCHE ... IT'S TIME FOR "HEE HAW"!!'" -- Berke Breathed, "Bloom County"

Paul Humphreys, ( Postmaster ) HR Wallingford, Howbery Park, Wallingford, Oxon England OX10 8BA


Tel 0491-35381 X2292 Fax 0491-32233

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:34 CDT