Path: utzoo!attcan!utgpu!watmath!uunet!lll-winken!csd4.milw.wisc.edu!mailrus!uflorida!indri!unmvax!tut.cis.ohio-state.edu!att!cbnewsc!levy From: levy@cbnewsc.ATT.COM (Daniel R. Levy) Newsgroups: unix-pc.general Subject: Re: crontab Daemon-from-Hell Summary: cd failure aborts /bin/sh script so / is safe. Message-ID: <1122@cbnewsc.ATT.COM> Date: 4 Jun 89 10:19:28 GMT References: <19071@cup.portal.com> <14373@bfmny0.UUCP> <1526@sialis.mn.org> <1528@sialis.mn.org> Organization: AT&T Bell Laboratories, Skokie IL Lines: 23 < >>> 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.