Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Every time I try to start postgresql, I get this error:

* Starting PostgreSQL 9.2 database server                                       
* Error: Could not create log file /var/log/postgresql/postgresql-9.2-main.log

To start the server, I have to sudo mkdir the postgresql folder in /var/log/

How can I start postgresql automatically every time I boot up? I already have a postgres user on the Ubuntu 12.10 system.

share|improve this question

migrated from Nov 9 '12 at 3:29

This question came from our site for professional and enthusiast programmers.

It looks like your /var/log/postgresql directory is wiped out at each reboot, which is unusual and not standard. Maybe /var/log is mounted on temporary storage or there's a custom script doing rm -rf /var/log/* or some such thing. – Daniel Vérité Nov 9 '12 at 2:45
That was it. It was getting wiped from the tmpfs. – nicefinly Nov 10 '12 at 22:21

Change the owner of the /var/log/postgresql directory to the postgres user:

chown postgres /var/log/postgresql
share|improve this answer
I just tried that, but the server still doesn't start at boot. – nicefinly Nov 9 '12 at 0:44

If you're using a .deb installation of Postgresql, it should be starting on boot up. However, since you're using a non-default Postgresql version -as I assume because Ubuntu 12.10 comes with 9.1.6-, probably it's not booting because of a non-compatible configuration. It's just a supposition.

Have a look at /etc/postgresql/9.2/main/start.conf, which should have the value auto to tell Ubuntu to start Postgresql on boot. (That file has fair simple docs about what each setting does).

share|improve this answer


It turns out I had included the /var/log/ folder in the tmpfs to be wiped every time I reboot, since I mounted the cache and temp in RAM to speed things up.

share|improve this answer
That's generally a bad idea; you'll find that if there's no regular fsync activity and you have a reasonably high dirty writeback threshold you won't actually gain tons from putting parts of /var in a tmpfs or ramdisk. It's also just not good sysadmin - the data is in /var not /tmp or /run for a reason. – Craig Ringer Dec 7 '14 at 12:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.