FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 02-18-2010, 05:01 PM
Geoffrey Leach
 
Default Cron says "bad command"

In /etc/crontab, I have this line:
30 * * * * /home/root/fix_mail

root@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@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?

Thanks.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-18-2010, 06:05 PM
Craig White
 
Default Cron says "bad command"

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@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@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.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-18-2010, 10:38 PM
Rick Sewill
 
Default Cron says "bad command"

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@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@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.



--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-19-2010, 09:31 PM
Geoffrey Leach
 
Default Cron says "bad command"

On 02/18/2010 03:38:55 PM, Rick Sewill wrote:
> 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@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@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.

Thanks Craig and Rick for the suggestions. AFAICT the problem is with
the processing of the crontab file itself, not with the execution of
the command. FWIW, when the command is executed from /etc/cron.hourly
it works without a problem.
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-19-2010, 09:51 PM
Konstantin Svist
 
Default Cron says "bad command"

On 02/18/2010 10:01 AM, Geoffrey Leach wrote:
> In /etc/crontab, I have this line:
> 30 * * * * /home/root/fix_mail
>
> root@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@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?
>
> Thanks.
>
>

You have your /root in /home?? That's unusual...
Maybe there's some permissions problem with /home?

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-19-2010, 10:12 PM
Geoffrey Leach
 
Default Cron says "bad command"

On 02/19/2010 02:51:56 PM, Konstantin Svist wrote:
> On 02/18/2010 10:01 AM, Geoffrey Leach wrote:
> > In /etc/crontab, I have this line:
> > 30 * * * * /home/root/fix_mail
> >
> > root@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@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?
> >
> > Thanks.
> >
> >
>
> You have your /root in /home?? That's unusual...
> Maybe there's some permissions problem with /home?

Hmmm .. just can't get no respect :-)

It may be unusual to have /root in /home, but it simplifies the
intallation of new versions of Fedora.

I finally gave in and read the source. It appears that cron requires a
user name before the command. That is,

* * * * * <username> command to be executed

in /etc/crontab entries.



--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-19-2010, 11:06 PM
Robert Nichols
 
Default Cron says "bad command"

Geoffrey Leach wrote:
> On 02/18/2010 03:38:55 PM, Rick Sewill wrote:
>> 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
[SNIP]
> Thanks Craig and Rick for the suggestions. AFAICT the problem is with
> the processing of the crontab file itself, not with the execution of
> the command. FWIW, when the command is executed from /etc/cron.hourly
> it works without a problem.

Ah, yes. The format of /etc/crontab is different from that for individual
users' crontab files. You need to include the user ID:

30 * * * * root /home/root/fix_mail
^^^^
--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 

Thread Tools




All times are GMT. The time now is 04:33 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org