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