Environmental Variables


You want to set something once and have it remembered between UNIX settings.



Set some variables. Simplest way to set environmental variables, is via the shell rc or profile scripts.



For example if your shell is zsh, use .zprofile or .zshrc. For bash it is .bashrc or .profile.

To invoke env vars from cron, use something like this:

30 * * * * zsh -c "(source $HOME/.zprofile; cmd ... ")

To source your .zprofile before command invocation. Additionally you can use a dot to source a script containing your vars:

. scriptname



[tags]UNIX, variables, shell scripting, Unix Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *