Cron says "bad command"

Rick Sewill rsewill at gmail.com
Thu Feb 18 23:38:55 UTC 2010


On Thu, 2010-02-18 at 12:05 -0700, Craig White wrote: 
> On Thu, 2010-02-18 at 10:01 -0800, Geoffrey Leach wrote:
> > In /etc/crontab, I have this line:
> > 30  *  *  *  *  /home/root/fix_mail
> > 
> > root at mtranch[221]->ls -l /home/root/fix_mail
> > -rwxr-xr-x 1 root root 1324 2010-02-18 07:04 /home/root/fix_mail*
> > 
> > Crond sees this and says (from /var/log/cron)
> > Feb 18 07:06:01 mtranch crond[1362]: (CRON) bad command (/etc/crontab)
> > 
> > /home/root/fix_mail is a perl script,
> > root at mtranch[222]->head -1 /home/root/fix_mail
> > #!/usr/bin/perl
> > 
> > And executes correctly when run from the command line.
> > 
> > Any thoughts on what the source of the complaint might be?
> ----
> generally people make the mistake of assuming an environment where a
> cron script would not have so for example, running...
> 
> ls assumes the environment of /bin so if you want to bury it in a script
> run from cron, you would replace 'ls' with '/bin/ls' if you want it to
> run... etc. Always provide absolute paths to scripts that may possibly
> be run without an environment. Don't take for granted that whatever you
> get for 'echo $PATH' will also be the same for a script.
> 
> Craig 
> 
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> 

Perhaps add an assignment to the BASH_ENV variable in the crontab file?
If your bash startup script is /root/.bash_profile, add
BASH_ENV=/root/.bash_profile
as the first line of the crontab file.





More information about the users mailing list