Thread: can't run pg_dump in sh script using crontab

can't run pg_dump in sh script using crontab

From
"Kogotkov, Vyacheslav"
Date:
   Dear colleagues,

   Besides I am new to Postgres, I am new to linux too.
   I have a sh-script which run pg_dump by hand successfully. But
I have no results when I run this script using crontab. I haven't got
any error log.
      Please, help me.
      Here is my sh-script:

#!/bin/sh
PG_BIN=/ora/pgsql/bin
BACKUP_DEST=/ora/home/FOR_POSTGRES/backup/dump
$PG_BIN/pg_dump -f $BACKUP_DEST/`date +%d%m%Y`_cspb.dmp dbname

   PG_VERSION contains 7.0.
   File HISTORY contains "Release 7.0.3".
   I have a single version of Postgres, so pg_dump
is the same version.
I connect to linux as user "oracle". He has an access to
database "dbname" and can SELECT data using psql. As far as
I remember, I create this database as user "oracle".
I usually start postmaster as user "oracle".
And I edit crontab as "oracle".
As "oracle", I can run this shell script by hand and get a good
dump file.
   But I get nothing if I run it using cron.
   I think, may be oracle pg_dump can't find database
"dbname" when it runs by crontab ?

   Thanks,
   Slava



Re: can't run pg_dump in sh script using crontab

From
Stefan Huber
Date:
>    But I get nothing if I run it using cron.
>    I think, may be oracle pg_dump can't find database
>"dbname" when it runs by crontab ?


Ist your crontab a systemwide one? (ie: /etc/crontab ?) this one's normally
run as root, but you may specify a special user. does your script run as
root, too? So you might ewant to un your script as
* * * * * su - oracle -c '/path/to/script/yourscript'

Stefan


Re: can't run pg_dump in sh script using crontab

From
Jie Liang
Date:
Hmm,

I run pg_dump with crontab seems OK.
I guess it might be some permission problem.
you may try your script with some debuging method like:
add set -x in your script and in cron pipe it to your email:
0    ??     *       *       *       youruser
fullpath/yourscript 2>&1| mail -s "test" yourmail@your.com

then you can figure out what's wrong.

Jie LIANG

St. Bernard Software
Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.stbernard.com
www.ipinc.com

On Sat, 10 Feb 2001, Kogotkov, Vyacheslav wrote:

>    Dear colleagues,
>
>    Besides I am new to Postgres, I am new to linux too.
>    I have a sh-script which run pg_dump by hand successfully. But
> I have no results when I run this script using crontab. I haven't got
> any error log.
>       Please, help me.
>       Here is my sh-script:
>
> #!/bin/sh
set -x
> PG_BIN=/ora/pgsql/bin
> BACKUP_DEST=/ora/home/FOR_POSTGRES/backup/dump
> $PG_BIN/pg_dump -f $BACKUP_DEST/`date +%d%m%Y`_cspb.dmp dbname
>
>    PG_VERSION contains 7.0.
>    File HISTORY contains "Release 7.0.3".
>    I have a single version of Postgres, so pg_dump
> is the same version.
> I connect to linux as user "oracle". He has an access to
> database "dbname" and can SELECT data using psql. As far as
> I remember, I create this database as user "oracle".
> I usually start postmaster as user "oracle".
> And I edit crontab as "oracle".
> As "oracle", I can run this shell script by hand and get a good
> dump file.
>    But I get nothing if I run it using cron.
>    I think, may be oracle pg_dump can't find database
> "dbname" when it runs by crontab ?
>
>    Thanks,
>    Slava
>
>


RE: can't run pg_dump in sh script using crontab

From
"Kogotkov, Vyacheslav"
Date:
  Jie,

  Thanks for your reply.
  I will try this.

  Regards,
  Slava

-----Original Message-----
From: Jie Liang [mailto:jliang@ipinc.com]
Sent: Monday, February 12, 2001 3:16 AM
To: Kogotkov, Vyacheslav
Cc: Pgsql-Admin@Postgresql. Org (E-mail)
Subject: Re: [ADMIN] can't run pg_dump in sh script using crontab



Hmm,

I run pg_dump with crontab seems OK.
I guess it might be some permission problem.
you may try your script with some debuging method like:
add set -x in your script and in cron pipe it to your email:
0    ??     *       *       *       youruser
fullpath/yourscript 2>&1| mail -s "test" yourmail@your.com

then you can figure out what's wrong.

Jie LIANG

St. Bernard Software
Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.stbernard.com
www.ipinc.com

On Sat, 10 Feb 2001, Kogotkov, Vyacheslav wrote:

>    Dear colleagues,
>
>    Besides I am new to Postgres, I am new to linux too.
>    I have a sh-script which run pg_dump by hand successfully. But
> I have no results when I run this script using crontab. I haven't got
> any error log.
>       Please, help me.
>       Here is my sh-script:
>
> #!/bin/sh
set -x
> PG_BIN=/ora/pgsql/bin
> BACKUP_DEST=/ora/home/FOR_POSTGRES/backup/dump
> $PG_BIN/pg_dump -f $BACKUP_DEST/`date +%d%m%Y`_cspb.dmp dbname
>
>    PG_VERSION contains 7.0.
>    File HISTORY contains "Release 7.0.3".
>    I have a single version of Postgres, so pg_dump
> is the same version.
> I connect to linux as user "oracle". He has an access to
> database "dbname" and can SELECT data using psql. As far as
> I remember, I create this database as user "oracle".
> I usually start postmaster as user "oracle".
> And I edit crontab as "oracle".
> As "oracle", I can run this shell script by hand and get a good
> dump file.
>    But I get nothing if I run it using cron.
>    I think, may be oracle pg_dump can't find database
> "dbname" when it runs by crontab ?
>
>    Thanks,
>    Slava
>
>