Skip to content
Advertisement

Tired of creating /run/postgresql and setting read and execute writes after every reboot

I’m running Arch Linux, I installed PostgreSQL as any other arch package. I’m running postgres with a local database located in my user directory. (postgres -D /home/user/data/) When I do so, I get the error FATAL: could not create lock file "/run/postgresql/.s.PGSQL.5432.lock": No such file or directory. Creating the directory /run/postgresql and giving the postgres user access solves this problem

$ sudo mkdir /run/postgresql
$ sudo chmod a+w /run/postgresql

however I’m tired of writing these commands every time I reboot, as /run gets cleared when rebooting. I could write a script to execute these commands, but I feel like I’m doing this the wrong way to begin with. Is there any way I could let postgres create its directory itself, or maybe have it not use /run/postgres for it’s lock files in the first place?

Advertisement

Answer

Postgres creates the lock file in /run/postgresql by default.

From the manpage:

  -k directory
          Specifies the directory of the Unix-domain socket on which postgres is
          to listen for connections from client applications. The default  is
          normally  /run/postgresql, but can be changed at build time.

Use -k directory to tell postgres to use a different directory.

Run your command as postgres -k /tmp -D /home/user/data/.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement