[ale] cron question

Jason Day jasonday at worldnet.att.net
Mon Jun 12 13:27:19 EDT 2006


On Sat, Jun 10, 2006 at 09:17:27AM -0400, Marvin,  International Martian of Mystery wrote:
> As you can see it's supposed to run every morning at 1 AM.  This is the
> script it's supposed to run:
> 
> 
> 
> #! /bin/sh
> 
> cd ./9
> 
> rm -Rf *
> 
> cd ../12
> 
> rm -Rf *

Ack!!  DO NOT DO THIS!!!

Note that if the first command fails (cd ./9), the next command will
still be executed, without having changed directories.  This means that
if the scripts starts in the root directory, and the "cd ./9" command
fails, then the "rm -Rf *" will happen in the root directory and delete
the entire contents of your drive.  Even if the script does not start in
/, it will still recursively delete everything in the current directory
if the cd command failed, which is probably not what you want.

Much better is to use something like:

/bin/rm -Rf /full/path/to/9/*
...

And as Geoffrey mentioned, you should use the full path to all commands,
in addition to the directories.

HTH,
Jason
-- 
Jason Day                                       jasonday at
http://jasonday.home.att.net                    worldnet dot att dot net
 
"Of course I'm paranoid, everyone is trying to kill me."
    -- Weyoun-6, Star Trek: Deep Space 9



More information about the Ale mailing list