Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 429097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:44:30+00:00 2026-05-12T19:44:30+00:00

Forgive my ignorance, but I am somewhat new to shell scripting and the use

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:44:30+00:00Added an answer on May 12, 2026 at 7:44 pm

    There’s your problem: cron doesn’t run /etc/profile.

    cron is started with only a tiny number of environment settings; anything else you need, you have to set up yourself, so it’s customary to have cron call a script to handle the setup and then the main action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You'll have to forgive my ignorance, but I'm not used to using wide character
I'm new to Python so forgive my ignorance If I don't have all the
I am relatively new to columnar database, please forgive ignorance. Lets say I have
Forgive my ignorance, but I am a beginner in java that comes from using
Please forgive the ignorance, but I'm very new to PHP and I couldn't find
Please forgive my ignorance, but I am very new to IOC and NinJect. I
Please forgive my ignorance, but I am noob. I have 4 Macs in my
I am very new to PHP, so forgive me my ignorance. I have HTML
Forgive me my ignorance but I am very new to the HTML 5 arena
Forgive my ignorance but I have a hard time remembering what I'm accessing in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.