Skip to content
Advertisement

How can l start postgresql database using linux crontab?

su - postgres
pg_ctl start

postgresql database is starting in this way.

but when I use linux crontab to start postgresql,it has failed.

su - postgres
crontab -e

*/1 * * * * nohup /home/postgres/pgsql/bin/pg_ctl start &

postgresql is not starting.

I want to know why.

Thank you!

Advertisement

Answer

You need to define which PostgreSQL instance to start.

Try to add -D "PGDATA".

For example:

nohup /home/postgres/pgsql/bin/pg_ctl start -D /pg/data &

If your Linux distribution is using systemd and a systemd unit has been defined for PostgreSQL you can also use systemctl to start PostgreSQL

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