unable to run postgres with pg_ctl I was reading a postgresql book (PostgreSQL from Novice to Pro) and it says you can start the postmaster daemon by invoking the postgres binary which was part of the installation:

/usr/lib/postgresql/9.3/bin/postgres "-D" "/var/lib/postgresql/9.3/main" "-c" "config_file=/etc/postgresql/9.3/main/postgresql.conf"


Notice we had to pass both the data directory and configuration as parameters to the postgres binary.

The book then goes on to say that the pg_ctl executable, which also happens to be stored in the /usr/lib/postgresql/9.3/bin directory when installing via apt-get, is used to simplify the task. But I cannot get pg_ctl to run:

$ /usr/lib/postgresql/9.3/bin/pg_ctl -D "/var/lib/postgresql/9.3/main" start
server starting
postgres@estonia:/usr/lib/postgresql/9.3/bin$ postgres cannot access the server configuration file "/var/lib/postgresql/9.3/main/postgresql.conf": No such file or directory


It says it cannot find the configuration file, but there is no way to specify the configuration file here:

$ /usr/lib/postgresql/9.3/bin/pg_ctl start "-D" "/var/lib/postgresql/9.3/main" "-c" "config_file=/etc/postgresql/9.3/main/postgresql.conf"
pg_ctl: too many command-line arguments (first is "start")
Try "pg_ctl --help" for more information.


How do I get pg_ctl to run?
When used to start the instance, pg_ctl accepts options to the postgres executable, passed with -o

From its manpage:


  -o options
       Specifies options to be passed directly to the postgres command.

       The options should usually be surrounded by single or double quotes
       to ensure that they are passed through as a group.



So your last command in the question should be amended as:

/usr/lib/postgresql/9.3/bin/pg_ctl start \
   "-D" "/var/lib/postgresql/9.3/main" \
   "-o -c config_file=/etc/postgresql/9.3/main/postgresql.conf"