Environment variables and cron | Unix Linux Forums | Solaris

  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


Closed Thread    
Thread Tools Search this Thread Display Modes
Old 08-02-2011
orange47 orange47 is online now
Registered User
Join Date: Dec 2010
Last Activity: 30 January 2015, 2:47 PM EST
Location: Yugoslavia
Posts: 272
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 ?

Sponsored Links
Old 08-02-2011
Skrynesaver's Avatar
Skrynesaver Skrynesaver is offline Forum Advisor  
Grumpy old geek
Join Date: Mar 2011
Last Activity: 30 January 2015, 10:16 AM EST
Location: Éire
Posts: 852
Thanks: 21
Thanked 197 Times in 193 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
Old 08-02-2011
ygemici ygemici is offline Forum Advisor  
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.

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

The Following User Says Thank You to ygemici For This Useful Post:
orange47 (08-02-2011)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 04:01 PM.