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

From Andreas Kretschmer
Subject Re: pg dump.. issue with when using crontab
Date
Msg-id 20100126170715.GA8550@tux
Whole thread Raw
In response to pg dump.. issue with when using crontab  (Moe <mohamed5432154321@gmail.com>)
List pgsql-general
Moe <mohamed5432154321@gmail.com> wrote:

> 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

Add the complete path to pg_dump, if it runs under cron it has not your
environment and not the PATH -> pg_dump was not found.


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

pgsql-general by date:

Previous
From: APseudoUtopia
Date:
Subject: Re: pg dump.. issue with when using crontab
Next
From: Keresztury Balázs
Date:
Subject: create role in a pl/pgsql trigger