RE: crontab

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

> -----Original Message-----
> From: redhat-list-bounces@xxxxxxxxxx 
> [mailto:redhat-list-bounces@xxxxxxxxxx] On Behalf Of Michael Velez
> Sent: Wednesday, May 25, 2005 4:52 PM
> To: 'General Red Hat Linux discussion list'
> Subject: RE: crontab
> 
>  
> 
> > -----Original Message-----
> > From: redhat-list-bounces@xxxxxxxxxx
> > [mailto:redhat-list-bounces@xxxxxxxxxx] 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@xxxxxxxxxxxxxx> 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@xxxxxxxxxx?subject=unsubscribe
> > > > https://www.redhat.com/mailman/listinfo/redhat-list
> > > > 
> > > 
> > > 
> > > 
> > > --
> > > Vipul Ramani
> > > linux2000in@xxxxxxxxx
> > > linux2000in@xxxxxxxxx
> > > ~~~~~We Know HOW NetWorkS ~~~~~
> > 
> > --
> > redhat-list mailing list
> > unsubscribe 
> mailto:redhat-list-request@xxxxxxxxxx?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
> 
> 
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 

The commands to test for environment variables are incorrect.

They should read:

# . ~root/.bash_profile
# . /etc/profile

However, without the first character '#'.  For some reason, if I have a '.'
as the first character on a line, my e-mail application (Microsoft Outlook)
deletes the '.'. The '.' saids to execute the file .bash_profile in the
current shell.  It will thus add environment variables to the shell.

I apologize for the confusion.

Michael

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux