A
A
Alexey2017-03-29 17:52:58
linux
Alexey, 2017-03-29 17:52:58

Binding file execution to initialization in terminal?

There are several variables that need to be permanently set after Posgresql initialization:

export PATH=/usr/local/pgsql/bin;
export PGDATA=/usr/local/pgsql/data;

I added them to .profile and put them in the root directory of Posgresql .
How can I make these variables auto-assign on initialization or in other words execute this file on login (even if I'm running Postgresql from a different directory?
f710a798c0ab4443b4c5119e12d11ff8.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xotkot, 2017-03-29
@aleksmanson

if using the bash shell , then:
for the user:

$ echo 'export PATH="$PATH:/usr/local/pgsql/bin"' >> ~/.bashrc
$ echo 'export PGDATA=/usr/local/pgsql/data' >> ~/.bashrc

or in ~/.bash_profile
if needed for the superuser (root), then put in /etc/profile:
# echo 'export PATH="$PATH:/usr/local/pgsql/bin"' >>/etc/profile
# echo 'export PGDATA=/usr/local/pgsql/data' >> /etc/profile

just don't forget to restart

I
ipc_ngs, 2017-03-29
@ipc_ngs

Use the -l switch when invoking su, this emulates the user's login and use of his .profile:
su -l postrgres

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question