Export variables within the script. How to crontab it?
Hi all, I'm writing my /bin/sh script that messes around with variables. Eventually I got to the point an need to export the variables.
Code:
export varialbe1=10 calling from sh: Code:
. ./variables.sh Code:
echo variable1: $variable1 How do I add an entry to the contable that achieves exactly what Code:
. /usr/local/bin/variables.sh Thanks |
You can simply put that code into your crontab or you can use the "source" command and reference the file or even simpler you can export your variables within the crontab itself.
---------- Post added 07-20-12 at 02:33 PM ---------- Also, /bin/sh is just a symlink to your current shell. Best practices are to path to the actual shell you want it to run under, /bin/bash or /bin/ksh for example. |
I've tried to just run the command from the crontable (without the dot in front), it doesn't seem to be working as the variables defined and exported within the script are not visible to e.g. an echo on the shell.
I don't have the source command either. I should have mentioned that I'm running this on a linux router running busybox. sh is the only option I have right now. |
cron jobs run in their own detached env.
They do not communicate with eg a login shell. |
As this runs on a router I "could" save on nvram but I know very well that this doesn't scale and also could damage the nvram if heavily used.
I ended up writing variables in a file, using a simple echo to inizialize the file and sed to replace values. In any case the linux filesystem in a router is entirely stored in RAM so it does the same and appears to be working fine. Thanks any ways |
All times are GMT -5. The time now is 08:02 AM. |