0

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?

nc4pk
9,26714 gold badges61 silver badges71 bronze badges
asked Feb 18, 2013 at 12:05

1 Answer 1

1

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.

answered Feb 18, 2013 at 12:38

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.