pg dump.. issue with when using crontab - Mailing list pgsql-general

From Moe
Subject pg dump.. issue with when using crontab
Date
Msg-id 861fed221001260854x355c62dbh622b6aea8e5a6208@mail.gmail.com
Whole thread Raw
Responses Re: pg dump.. issue with when using crontab  (APseudoUtopia <apseudoutopia@gmail.com>)
Re: pg dump.. issue with when using crontab  (Andreas Kretschmer <akretschmer@spamfence.net>)
Re: pg dump.. issue with when using crontab  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi folks,

I have a simple script file db :
#!/bin/bash
pg_dump -U postgres prodDB > /var/a/db/$(date "+%Y-%m-%d_%H:%M")-prodDB.dump

----------
Which works fine when executed manually ( ./db ).. I get a dump file which is around 1.9 MB


I run this script from the crontab schedueler (crontab -e) :

# m h  dom mon dow   command
33 04 * * * /var/a/scripts/db

Which appears to executing the script file, but what I get is zero sized dump files.
So perhaps it is some use access that is limiting crontab, making it not run as root.

How can I fix this to work with crontab ? I am thinking that I should change :
pg_dump -U postgres prodDB > /var/a/db/$(date "+%Y-%m-%d_%H:%M")-prodDB.dump

Thank you in advance / Moe

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Make & Install contrib/tablefunc Problems
Next
From: APseudoUtopia
Date:
Subject: Re: pg dump.. issue with when using crontab