sourcing in perlscript run by crontab
Andrew Glen-Young
aglenyoung at gmail.com
Sat Oct 20 21:51:34 UTC 2007
On 20/10/2007, Arun <arun.george.1981 at gmail.com> wrote:
> Hi All,
>
> I have a crontab which calls a perlscript for building my project. I am
> using the environment variabel CATALINA_HOME in it.
> If I run the perl script manually the value of ${CATALINA_HOME} is correctly
> interperetted.
> But when I run the same perl script thru crontab the value is empty. I tried
> sourcing the .bashrc file which contains the value.
> export CATALINA_HOME='/usr/local/bin/apache-tomcat-6.0.13'
> Even then the perl script that is run as crontask mistook the variable
> having an empty value.
>
> What might be the reasons.?
>
I suggest that you have a thorough read of the crontab(5) man page.
Cron will run with a restricted environment. If you want to use an
environment variable, you will have to set it in the crontab or the
script itself. Look for the 'EXAMPLE CRON FILE' section. Bash will not
source your .bashrc or .bash_profile scripts when it is not run
interactively and so any environment variables defined in these files
will not be available to your crontab. Read the 'INVOCATION' section
of the bash(1) man page for more.
Regards.
Andrew Glen-Young
More information about the ubuntu-users
mailing list