如何使用linux crontab启动postgresql数据库?

如何使用linux crontab启动postgresql数据库?,linux,postgresql,cron,Linux,Postgresql,Cron,postgresql数据库正以这种方式启动 但当我使用linux crontab启动postgresql时,它失败了 su - postgres pg_ctl start postgresql没有启动 我想知道为什么 谢谢大家! 您需要定义启动哪个PostgreSQL实例 尝试添加-D PGDATA 例如: su - postgres crontab -e */1 * * * * nohup /home/postgres/pgsql/bin/pg_ctl start & 如果您的L

postgresql数据库正以这种方式启动

但当我使用linux crontab启动postgresql时,它失败了

su - postgres
pg_ctl start
postgresql没有启动

我想知道为什么


谢谢大家!

您需要定义启动哪个PostgreSQL实例

尝试添加-D PGDATA

例如:

su - postgres
crontab -e

*/1 * * * * nohup /home/postgres/pgsql/bin/pg_ctl start &
如果您的Linux发行版正在使用systemd,并且已经为PostgreSQL定义了systemd单元,那么您也可以使用systemctl来启动PostgreSQL

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