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

2011-11-09 Thread Greg Wooledge
On Tue, Nov 08, 2011 at 09:46:37PM -0600, Peng Yu wrote: > I need to use cron to run some job. I know that cron only set up very > basic environment. I'd like to duplicate my login environment. Just source /etc/profile and your ~/.bash_profile or ~/.profile (or whatever) from the script that your

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

2011-11-09 Thread Peng Yu
On Wed, Nov 9, 2011 at 7:45 AM, Greg Wooledge wrote: > On Tue, Nov 08, 2011 at 09:46:37PM -0600, Peng Yu wrote: >> I need to use cron to run some job. I know that cron only set up very >> basic environment. I'd like to duplicate my login environment. > > Just source /etc/profile and your ~/.bash_p

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

2011-11-09 Thread Peng Yu
On Wed, Nov 9, 2011 at 7:45 AM, Greg Wooledge wrote: > On Tue, Nov 08, 2011 at 09:46:37PM -0600, Peng Yu wrote: >> I need to use cron to run some job. I know that cron only set up very >> basic environment. I'd like to duplicate my login environment. > > Just source /etc/profile and your ~/.bash_p

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

2011-11-09 Thread Greg Wooledge
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 s

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

2011-11-09 Thread Peng Yu
On Wed, Nov 9, 2011 at 10:41 AM, Greg Wooledge 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?

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

2011-11-09 Thread Eric Blake
On 11/09/2011 10:14 AM, Peng Yu wrote: variable assignment VAR=blah. That sets up a bash-local variable. If you want it to be exported to the environment visible to child processes, then you _also_ need to use export, as in either: VAR=blah export VAR or export VAR=blah However, VAR i