2

I want to declare a variable in such way that every script can access and alter its value.

I have written a script that set the value of a variable called flag on exit and I am using a crontab entry to run it every minute. I want flag value to be initialized from previous exit value. Is there any way to do so?

4

If you insert

echo "prevexit=3" > ~/.prevexit

at the end of your crontab initiated command, then you can use:

source ~/.prevexit

close to the top of all the scripts that need to include the value, and use it in the rest of those scripts as $prevexit.

You should of course replace 3 with the real value you want to share.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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