Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

export variable in bash shell script

Status
Not open for further replies.

ranjank

IS-IT--Management
May 9, 2003
176
IN
Hi,

I want to set the variable which i had exported in shell script, in my home path from where i will be running the script.One thing i know is to source a file like for e.g:--

source script
or
. ./filename

The problem is i want to set it in the cron job and want to source a script.My script is a small build script written in bash shell and first it exports a variable and then build it.

Any help on this will be highly appreciated.

Regards,
Ranjan.
 
Hi ranjan,

Usually CRON's run SH and not BASH.

But try this:

In your CRON entry you just source the file with the variable(s) that'll be used:

Code:
00 10 * * * . /PATH_TO/.SOUCE_FILE; /export/home/YOU/cron/bin/SCRIPT > /export/home/YOU/cron/log/SCRIPT.log 2>&1 &

Good Luck
DrD
 
Why not just source it as one of the first lines in the script? That way it always has the variables defined no matter who runs it or how.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top