Ultrix' /etc/crontab as a time-bomb [short joke].
Or perhaps a better solution:
find /usr/preserve -mtime +7 -a -exec rm -f {} \;
On Thu, 21 Mar 2002, Pete Turnbull wrote:
> On Mar 20, 18:05, Gunther Schadow wrote:
> > Hihi, our little training in risk-assessment tonight is the following
> > sippet of a crontab entry, scheduled to run dayly around midnight:
> >
> > (cd /usr/preserve ; find . -mtime +7 -a -exec rm -f {} \;)
> >
> > why is this a bad idea and what happened to me last night as I was
> > playing with my VAX6460?
>
> Because Bad Things happen if the cd fails...
>
> > Answer: the /usr/preserve was a symlink to /usr/var/preserve which
> > didn't exist. What happened next?
>
> > All files that were not accessed for more than 7 days were being deleted
>
> The correct way to do someting like this in a cron entry is to check the
> return code from the cd command, and only execute the rest of the command
> if the cd succeeds, eg
>
> (cd /usr/preserve && find . -mtime +7 -a -exec rm -f {} \;)
>
> --
> Pete Peter Turnbull
> Network Manager
> University of York
>
Received on Thu Mar 21 2002 - 19:36:24 GMT
This archive was generated by hypermail 2.3.0
: Fri Oct 10 2014 - 23:35:13 BST