Environmental Variables

Problem

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



Solution

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



Example


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



Reference

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



Leave a Reply

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