bug-bash
[Top][All Lists]
Advanced

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

Re: What is the correct way to set up login environment in crontab?


From: Peng Yu
Subject: Re: What is the correct way to set up login environment in crontab?
Date: Wed, 9 Nov 2011 11:14:00 -0600

On Wed, Nov 9, 2011 at 10:41 AM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> On Wed, Nov 09, 2011 at 10:29:52AM -0600, Peng Yu wrote:
>> I sourced my ~/.bashrc, which source some other files. It seems the
>> environment variables defined in these files are not seen with env.
>> Why is so?
>
> Without seeing the code?  Impossible to say.  But you're doing it backwards.
> ~/.bashrc should be sourced FROM ~/.bash_profile.  A login shell reads
> ~/.bash_profile only, so it's the responsibility of ~/.bash_profile to
> read ~/.bashrc to set up aliases, functions, shopts, and other ephemeral
> shell settings that can't be inherited from the environment.

Sorry for the confusion. ~/.bash_profile is not the problem here. I
have the following line in /path/programtorun.sh

. ~/.bashrc

In ~/.bashrc, I have ". ~/bash_some". In ~/.bash_some, I have some
variable assignment VAR=blah.

However, VAR is not seen in env in /path/programtorun.sh (called from cron).

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]