Environment variables and cron | Unix Linux Forums | Solaris

  Unix/Linux Go Back    


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

Environment variables and cron

Solaris


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-02-2011
orange47 orange47 is offline
Registered User
 
Join Date: Dec 2010
Last Activity: 3 March 2015, 4:57 PM EST
Location: Yugoslavia
Posts: 274
Thanks: 68
Thanked 11 Times in 11 Posts
Environment variables and cron

where do you set environment variables for cron jobs?
I have a feeling it would ignore ~/.bashrc ?

thanks.
Sponsored Links
    #2  
Old Unix and Linux 08-02-2011
Skrynesaver's Unix or Linux Image
Skrynesaver Skrynesaver is offline Forum Advisor  
Grumpy old geek
 
Join Date: Mar 2011
Last Activity: 5 March 2015, 3:20 PM EST
Location: Éire
Posts: 861
Thanks: 21
Thanked 201 Times in 197 Posts
You can have a file that declares and exports them which you source as the first step in your command... there are no guarantees WRT the shell cron runs in.
The Following User Says Thank You to Skrynesaver For This Useful Post:
orange47 (08-02-2011)
Sponsored Links
    #3  
Old Unix and Linux 08-02-2011
ygemici ygemici is offline Forum Advisor  
sed_shell@LNU
 
Join Date: Feb 2010
Last Activity: 20 January 2015, 10:39 AM EST
Location: istanbul
Posts: 1,688
Thanks: 3
Thanked 289 Times in 281 Posts
what is your os and bash version? do you have a .bashrc file?
if you want to set enviroments globaly,you can edit /etc/default/cron.
or you can add bash startup scripts to your cron scripts.

Code:
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
if [ -f ~/.bash ]; then
. ~.bash_profile
fi

regardss
ygemici
The Following User Says Thank You to ygemici For This Useful Post:
orange47 (08-02-2011)
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Setting environment variables in Cron file shyamu544 Shell Programming and Scripting 4 07-20-2011 05:43 AM
environment variables radhika03 Shell Programming and Scripting 3 01-22-2007 01:58 PM
Setting environment variables within cron jobs!! atheek Solaris 1 10-09-2006 08:26 AM
Cron Environment Smitty McSmith UNIX for Dummies Questions & Answers 8 07-13-2005 07:31 PM
environment variables Esaia Programming 2 02-20-2003 08:19 PM



All times are GMT -4. The time now is 10:25 PM.