Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a shell script that exports values of variables when executed. The same values will be used in another script.

#!/bin/sh
export I="10"
echo $I

I will be using root access for cron. I tried this command:

*/5 * * * * /home/ubuntu/backup/.test.sh

After it ran, I checked the environment variables, and nothing was updated.

How do I run this script in cron and get it to properly export variables?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

export only makes variables available to sub processes, not to existing shells, or even shells that run later.

Only those called by test.sh would see the new environment variables.

While this answers your question, you may want to edit it to describe what you are trying to achieve - why you want to do this, so that you'll get better answers, different approaches.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.