I have set a cron job to take backup the database every hour.
0 */1 * * * sh /opt/post.sh
pg_dump -U postgres db_name > /home/golp/Desktop/backup.sql
For authentication, I am using .pgpass file.
chmod 0600 ~/.pgpass chown postgres:postgres /home/golp/Desktop/
The cron job seems to run every hour (I checked the log). I find that the backup file created by cron job is empty. I am using CentOS 7 1503 and Postgresql 9.5
NOTE: When I run
pg_dump -U postgres db_name > /home/golp/Desktop/backup.sql as root user in terminal, backup is created as expected.