Обсуждение: can't run pg_dump in sh script using crontab

Поиск
Список
Период
Сортировка

can't run pg_dump in sh script using crontab

От
"Kogotkov, Vyacheslav"
Дата:
      Dear colleagues,

      I have a sh-script which run pg_dump by hand successfully. But
I have no results when I run this script using crontab. Unfortunately, I'm
new for Postgres and even have no idea, what the matter. I can't get
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

     Thanks,
     Slava


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

От
"Kogotkov, Vyacheslav"
Дата:
   Hello Mitch,

   Thank you for your fast reply.
   Besides I am new to Postgres, I am new to linux too.

   PG_VERSION contains 7.0
   I have a single version of Postgres, so pg_dump
is the same version. File HISTORY contains "Release 7.0.3".
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


-----Original Message-----
From: Mitch Vincent [mailto:mitch@venux.net]
Sent: Friday, February 09, 2001 10:03 PM
To: Kogotkov, Vyacheslav
Subject: Re: can't run pg_dump in sh script using crontab


You probably aren't running pg_dump as the user that has access to
PostgreSQL.

-Mitch

----- Original Message -----
From: "Kogotkov, Vyacheslav" <Vyacheslav.Kogotkov@artificial-life.com>
To: "PostgreSQL General" <pgsql-general@postgresql.org>
Sent: Friday, February 09, 2001 1:58 PM
Subject: can't run pg_dump in sh script using crontab


>       Dear colleagues,
>
>       I have a sh-script which run pg_dump by hand successfully. But
> I have no results when I run this script using crontab. Unfortunately, I'm
> new for Postgres and even have no idea, what the matter. I can't get
> 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
>
>      Thanks,
>      Slava
>
>

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

От
"Richard Huxton"
Дата:
From: "Kogotkov, Vyacheslav" <Vyacheslav.Kogotkov@artificial-life.com>

>    PG_VERSION contains 7.0
>    I have a single version of Postgres, so pg_dump
> is the same version. File HISTORY contains "Release 7.0.3".
> 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 ?

Make sure you set any environment variables you need. You are probably
missing a path or one of the PGxxx environment vars.

- Richard Huxton


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

От
"Kogotkov, Vyacheslav"
Дата:
   Thank you for your help.

   I managed to get an output by mail:

"/opt/postgresql/bin/pg_dump: error in loading shared libraries:
libpq.so.2.1: cannot open shared object file: No such file or directory"

   I've just found a solution from old postgresql archive:
"You can just put the postgresql lib directory in /etc/ld.so.conf and run
ldconfig."
   It seems to be working. I've just got a dump file.
   But I have a question: is this solution enough for successful pg_dump
or I have to do something else to exclude failure ?

   Thanks
   Slava


-----Original Message-----
From: Richard Huxton [mailto:dev@archonet.com]
Sent: Saturday, February 10, 2001 6:38 PM
To: Kogotkov, Vyacheslav
Cc: pgsql-general
Subject: Re: [GENERAL] RE: can't run pg_dump in sh script using crontab


From: "Kogotkov, Vyacheslav" <Vyacheslav.Kogotkov@artificial-life.com>

>    PG_VERSION contains 7.0
>    I have a single version of Postgres, so pg_dump
> is the same version. File HISTORY contains "Release 7.0.3".
> 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 ?

Make sure you set any environment variables you need. You are probably
missing a path or one of the PGxxx environment vars.

- Richard Huxton