crontab Daemon-from-Hell

Daniel R. Levy levy at cbnewsc.ATT.COM
Sun Jun 4 20:19:28 AEST 1989


< >>>	cd /usr/spool/uucppublic
< >>>	find . -type f -mtime +30 -exec rm -f {} \;
< >>
< >>This is dangerous if run as root.  If anything - disk error, anything - 
< >>happens to make /usr/spool/uucppublic unavailable, you will wipe your
< >>file structure.
[ presumably because the cd will fail, leaving the current directory to be / ]

Under Bourne shell (/bin/sh), if cd fails the script aborts with an
error message.  Presumably, cron is using /bin/sh, so even if there
is no /usr/spool/uucppublic the cron entry won't trash the disk starting
from /.

(Note, however, that a failed cd will NOT abort a script running under ksh.
I have been bitten by that one because ksh runs script commands invoked
from it with another ksh, and some sh scripts depend upon a script
aborting upon a failed cd rather than blithely plunging on with nothing
more than an error message.)
-- 
Daniel R. Levy             UNIX(R) mail:  att!ttbcad!levy, att!cbnewsc!levy
AT&T Bell Laboratories
5555 West Touhy Avenue     Any opinions expressed in the message above are
Skokie, Illinois  60077    mine, and not necessarily AT&T's.



More information about the Unix-pc.general mailing list