Jump to content

[Answered] Run a cron job for PostgreSQL database maintenance


systemcr

Recommended Posts

Hello,

 

I'd like to know if I can use 'psql' instead of 'php' to run a daily maintenance SQL script on my PostgreSQL database as a cron job from cPanel.

 

The command line to execute would be something similar to the following, according to https://dba.stackexchange.com/questions/157991/how-to-create-jobs-in-postgresql/157992#157992

psql -d myDb -f "maintenance.sql"

Thank you very much in advance.

Link to comment
Share on other sites

I don't see why not, but I'm not sure whether the cron will have the access necessary to connect to your databases when it runs.

 

The cron should run as your user account. If you need to provide other credentials, read up on the .pgpass file. You can create it and put it in your home folder to provide credentials for psql to use.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...