systemcr Posted January 6, 2020 Posted January 6, 2020 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.
wolstech Posted January 6, 2020 Posted January 6, 2020 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now