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?
1 Answer 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.