crontab

Michael Velez mikev777 at hotmail.com
Wed May 25 20:52:16 UTC 2005


 

> -----Original Message-----
> From: redhat-list-bounces at redhat.com 
> [mailto:redhat-list-bounces at redhat.com] On Behalf Of Muhammad Rizwan
> Sent: Wednesday, May 25, 2005 2:14 AM
> To: Vipul Ramani; General Red Hat Linux discussion list
> Subject: Re: crontab
> 
> 
> YES
> 
> On Tue, 2005-05-24 at 23:35, Vipul Ramani wrote:
> > Hi,
> >  did u make executable to your shell script. ???
> >   Regards,
> > 
> >  On 5/23/05, Manuel Arostegui Ramirez 
> <manuel at todo-linux.com> wrote: 
> > > 
> > > El Lunes 23 Mayo 2005 10:00, Muhammad Rizwan escribió:
> > > > I have my script that is running fine when i run it as: 
> /root/shelltest.
> > > > But when i try to run it from crontab its not working 
> at all. My 
> > > > entry in crontab is: 2 * * * * /root/shelltest.
> > > > Any idea?
> > > >
> > > > Thanks
> > > 
> > > Try with this line:
> > > 2 * * * * root /root/shelltest
> > > 
> > > 
> > > --
> > > Manuel Arostegui Ramirez #Linux Registered User 295750 Socio de 
> > > Hispalinux 1813 Red Hat Linux 9, Kernel 2.6.2 ReiserFS 
> Firma cifrada 
> > > -----BEGIN PGP SIGNATURE-----
> > > Version: GnuPG v1.0.6 (GNU/Linux)
> > > Comment: For info see http://www.gnupg.org
> > > iD8DBQE+3O1MqfmPcHTj+twRAm
> > > yDAJ9P6ezepIMg06vOet/YPKxVoB+Z/ACfWVhh
> > > ---END PGP SIGNATURE-----
> > > 
> > > --
> > > redhat-list mailing list
> > > unsubscribe 
> > > mailto:redhat-list-request at redhat.com?subject=unsubscribe
> > > https://www.redhat.com/mailman/listinfo/redhat-list
> > > 
> > 
> > 
> > 
> > --
> > Vipul Ramani
> > linux2000in at gmail.com
> > linux2000in at yahoo.com
> > ~~~~~We Know HOW NetWorkS ~~~~~
> 
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 

Two things:

- Are you sure cron is starting the right shell for you?  Are you specifying
the shell command you want to start in your shell script.

For example, if you wrote your script in bash syntax, the first line needs
to be:

#!/bin/bash

- Does your shell script use root environment variables (which get sourced
when initializing a root login shell but not when cron starts a shell
script).

To test this out add the following commands in your shell script:

 ~root/.bash_profile
 /etc/profile

or whichever file gest sourced when you login as root (.bashrc, etc.)

It's best to initialize only those variables which your script uses.  So if
the above works for you, try to isolate the variables you need (i.e.
HOSTNAME, USERNAME).

The error you're getting may not necessarily indicate an environment
variable issue, but I once had a shell script started in cron which was
giving me a syntax error only because an environment variable was not set.

Hope this helps,
Michael





More information about the redhat-list mailing list