For User & Application
There are actully three files from the linux reads the enviroment variable- /etc/enviromet
- ~/.profile :
- ~/.bashrc
If your app depened on the enviroment variable then you have to store that variable inside this files otherwise those variable lost as soon as the terminal exits.
To export enviroment variable permanatly in linux follow this commands :
$ echo export variablename='path/value' >> ~/.profile
This will store the variable in the ~./profile
$ echo export variablename='path/value' >> ~/.bashrc
This will store the variable in the ~./bashrc
Now to make this change working you have to run this commands
$ source ~/.profile
This will evaluate ~/.profile file
$ source ~/.bashrc
This will evaluate ~/.bashrc file
You can locate this files in you users Home folder
bashrc and profile files |
If you want to go GUI way you can find this files in your /home/[user] folder
bashrc file |
For CronJob
This will not work if you have to use the enviroment variable in the cron job
If you want to set the enviroment variable for cron job. Then you have to define that variable in the crontab as well
$crontab -e
This will open the crontab. Here define the variable in this file as i have defined the GOOGLE_APPLICATION_CREDENTAILS in image
Define Enviroment variable for cron job |
Comments
Post a Comment