Forgive my ignorance, but I am somewhat new to shell scripting and the use of environment variables in Linux.
I have a script that performs a backup of a MySQL database. I have the following lines in the script that are used to log a successful dump of the database:
output=`date; echo "Database export successful from $ENV_HOSTNAME to $BACKUP_HOSTNAME"`
echo $output >> /var/log/errorLog
I have the variables (ENV_HOSTNAME and BACKUP_HOSTNAME) defined in /etc/profile as follows:
export ENV_HOSTNAME="env1.somename.com"
export BACKUP_HOSTNAME="env2.somename.com"
I can see these variables listed when I call printenv and the variable values appear in the log file correctly when I run this script (as root). However, when I set this script to run using cron, the variable values are not appearing in the log file. I know that script runs because I can see the date and the rest of string, but the variables are blank:
Fri Nov 6 22:31:05 EST 2009 Database export successful from to
I'm sure I am missing something simple here, so thank you in advance for the help.