Thread: Re: vacuumdb and pg_dump are not running under cron

Re: vacuumdb and pg_dump are not running under cron

From
Jason Tishler
Date:
Jeff,

On Mon, May 12, 2003 at 11:42:42AM -0400, Jeff Lu wrote:
> I set up a cron job to run vacuumdb and pg_dump periodically but they
> are not being run under cron.  Under command line they worked fine.
>
> At first I thought the cron didn't get executed at all so I added
> shutdown to in my cron file:
>
> 9 12 * * * vacuumdb --username=jeff -h localhost jeffdb
> 9 12 * * * pg_dump --username=jeff jeffdb > /c/progra~1/apache~1/apache/
> intrapos/database/intrapos_shdw.dat
> 9 12 * * * pg_ctl stop -m fast

Shouldn't the above be in a shell script?  In this way, the commands
will be executed sequentially.  Executing them concurrently does not
seem to be what you intended.

> 9 12 * * * shutdown --force --shutdown 10

The above is a harsh way to determine whether or not cron is working.  I
would use the following test instead:

    */1 * * * * date >>/tmp/date.txt

> The system got shutdown but the database didn't get stopped, vaccumdb and
> pg_dump did not get executed
>
> Can someone tell me why that is?

See above.

To further debug this problem, I would do one of the following:

    1. set up ssmtp and set MAILTO as appropriate
    2. redirect stdout and stderr to a log file

so cron can inform you of any output (i.e., errors) from the cron jobs.

BTW, what user is the crontab running under?  Is it the same one as used
during the command line testing?

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


Re: vacuumdb and pg_dump are not running under cron

From
Jason Tishler
Date:
Jeff,

On Mon, May 12, 2003 at 12:29:50PM -0400, Jeff Lu wrote:
> Actually I do have these in a shell script file name "backupsys"
> vacuumdb --username=jeff -h localhost jeffdb
> pg_dump --username=jeff jeffdb >> /c/progra~1/apache~1/apache/ intrapos/database/intrapos_shdw.dat
> pg_ctl stop -m fast

Good.

> My cron really looks like this:
> 9 12 * * * /c/progra~1/apache~1/apache/cgi-bin/backupsys

Change the above to the following:

    9 12 * * * /c/progra~1/apache~1/apache/cgi-bin/backupsys >>/tmp/backupsys.log 2>&1

Does examining the contents of /tmp/backupsys.log help you debug the
problem?

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


Re: vacuumdb and pg_dump are not running under cron

From
Jason Tishler
Date:
Jeff,

On Mon, May 12, 2003 at 02:57:32PM -0400, Jeff Lu wrote:
> I'm getting permission denied
>
> VACUUM
> /c/progra~1/apache~1/apache/cgi-bin/monday: cannot create
> /c/progra~1/apache~1/apache/intrapos/database/intrapos_mon.dat: permission denied

OK, so fix your permission problems.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


Re: vacuumdb and pg_dump are not running under cron

From
Jason Tishler
Date:
Jeff,

Please keep your replies on-list.

On Mon, May 12, 2003 at 03:26:48PM -0400, Jeff Lu wrote:
> I do not have permission problem when executing the script file from a
> command line

Does the cron job run as the same user as the one invoking the command
line?  For example, what does the following cron job indicate?

    */1 * * * * id >>/tmp/id.txt

And, what does the following indicate?

    $ id

Do they agree?

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


Re: vacuumdb and pg_dump are not running under cron

From
Jason Tishler
Date:
Jeff,

On Mon, May 12, 2003 at 03:55:17PM -0400, Jeff Lu wrote:
> From $ id
> uid=500(Administrator) gid=513(None) groups=544(Administrators),545(Users)
>
> From cron
> uid=500(Administrator) gid=513(None) groups=513(None),545(Users)
>
> The groups are different.  Why is that?

Sorry, I don't know.  Is your /etc/passwd and /etc/group files set up
correctly?  Is cron really switching users correctly?

BTW, I get the following:

    $ id
    uid=19695(jt) gid=10513(Domain Users) groups=544(Administrators),545(Users),10513(Domain Users)

    $ cat /tmp/id.txt
    uid=19695(jt) gid=10513(Domain Users) groups=544(Administrators),545(Users),10513(Domain Users)

Sounds like your Cygwin setup is not correct.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


Re: vacuumdb and pg_dump are not running under cron

From
Jason Tishler
Date:
Jeff,

On Mon, May 12, 2003 at 04:37:14PM -0400, Jeff Lu wrote:
> I don't know.  How do I know if cron is switching user correctly? How
> can I reconfigure /etc/passwd and /etc/group files so cron will work
> correctly?  Will mkgroup and mkpass correct this problem?

Unless you are really running under the local administrator's account,
then it appears that your /etc/passwd and /etc/group files need to be
regenerated with mkpasswd and mkgroup, respectively.

Please take this problem to the Cygwin list <cygwin@cygwin.com> since
this is really OT for this one.  Additionally, since there are more
experienced Cygwin users there, your problem is likely to be solved
faster than here.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


Re: vacuumdb and pg_dump are not running under cron

From
"Jeff Lu"
Date:
Jason,

Actually I do have these in a shell script file name "backupsys"
vacuumdb --username=jeff -h localhost jeffdb
pg_dump --username=jeff jeffdb >
> /c/progra~1/apache~1/apache/ intrapos/database/intrapos_shdw.dat
pg_ctl stop -m fast

My cron really looks like this:
9 12 * * * /c/progra~1/apache~1/apache/cgi-bin/backupsys

Thanks
-Jeff


-----Original Message-----
From: Jason Tishler [mailto:jason@tishler.net]
Sent: Monday, May 12, 2003 12:11 PM
To: Jeff Lu
Cc: pgsql-cygwin@postgresql.org
Subject: Re: vacuumdb and pg_dump are not running under cron


Jeff,

On Mon, May 12, 2003 at 11:42:42AM -0400, Jeff Lu wrote:
> I set up a cron job to run vacuumdb and pg_dump periodically but they
> are not being run under cron.  Under command line they worked fine.
>
> At first I thought the cron didn't get executed at all so I added
> shutdown to in my cron file:
>
> 9 12 * * * vacuumdb --username=jeff -h localhost jeffdb
> 9 12 * * * pg_dump --username=jeff jeffdb >
> /c/progra~1/apache~1/apache/ intrapos/database/intrapos_shdw.dat
> 9 12 * * * pg_ctl stop -m fast

Shouldn't the above be in a shell script?  In this way, the commands
will be executed sequentially.  Executing them concurrently does not
seem to be what you intended.

> 9 12 * * * shutdown --force --shutdown 10

The above is a harsh way to determine whether or not cron is working.  I
would use the following test instead:

    */1 * * * * date >>/tmp/date.txt

> The system got shutdown but the database didn't get stopped, vaccumdb
> and pg_dump did not get executed
>
> Can someone tell me why that is?

See above.

To further debug this problem, I would do one of the following:

    1. set up ssmtp and set MAILTO as appropriate
    2. redirect stdout and stderr to a log file

so cron can inform you of any output (i.e., errors) from the cron jobs.

BTW, what user is the crontab running under?  Is it the same one as used
during the command line testing?

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


Re: vacuumdb and pg_dump are not running under cron

From
"Jeff Lu"
Date:
Jason,

I'm getting permission denied

VACUUM
/c/progra~1/apache~1/apache/cgi-bin/monday: cannot create
/c/progra~1/apache~1/apache/intrapos/database/intrapos_mon.dat:
permission denied



-----Original Message-----
From: Jason Tishler [mailto:jason@tishler.net]
Sent: Monday, May 12, 2003 12:43 PM
To: Jeff Lu
Cc: pgsql-cygwin@postgresql.org
Subject: Re: vacuumdb and pg_dump are not running under cron


Jeff,

On Mon, May 12, 2003 at 12:29:50PM -0400, Jeff Lu wrote:
> Actually I do have these in a shell script file name "backupsys"
> vacuumdb --username=jeff -h localhost jeffdb pg_dump --username=jeff
> jeffdb >> /c/progra~1/apache~1/apache/
> intrapos/database/intrapos_shdw.dat
> pg_ctl stop -m fast

Good.

> My cron really looks like this:
> 9 12 * * * /c/progra~1/apache~1/apache/cgi-bin/backupsys

Change the above to the following:

    9 12 * * * /c/progra~1/apache~1/apache/cgi-bin/backupsys
>>/tmp/backupsys.log 2>&1

Does examining the contents of /tmp/backupsys.log help you debug the
problem?

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


Re: vacuumdb and pg_dump are not running under cron

From
"Jeff Lu"
Date:
From $id
uid=500(Administrator) gid=513(None)
groups=544(Administrators),545(Users)

From cron
uid=500(Administrator) gid=513(None) groups=513(None),545(Users)

The groups are different.  Why is that?

Thanks
-Jeff

-----Original Message-----
From: Jason Tishler [mailto:jason@tishler.net]
Sent: Monday, May 12, 2003 3:38 PM
To: Jeff Lu
Cc: Pgsql-Cygwin
Subject: Re: vacuumdb and pg_dump are not running under cron


Jeff,

Please keep your replies on-list.

On Mon, May 12, 2003 at 03:26:48PM -0400, Jeff Lu wrote:
> I do not have permission problem when executing the script file from a

> command line

Does the cron job run as the same user as the one invoking the command
line?  For example, what does the following cron job indicate?

    */1 * * * * id >>/tmp/id.txt

And, what does the following indicate?

    $ id

Do they agree?

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


Re: vacuumdb and pg_dump are not running under cron

From
"Jeff Lu"
Date:
Sorry Jason,

I don't know.  How do I know if cron is switching user correctly? How
can I reconfigure /etc/passwd and /etc/group files so cron will work
correctly?  Will mkgroup and mkpass correct this problem?



-----Original Message-----
From: Jason Tishler [mailto:jason@tishler.net]
Sent: Monday, May 12, 2003 4:02 PM
To: Jeff Lu
Cc: 'Pgsql-Cygwin'
Subject: Re: vacuumdb and pg_dump are not running under cron


Jeff,

On Mon, May 12, 2003 at 03:55:17PM -0400, Jeff Lu wrote:
> From $ id
> uid=500(Administrator) gid=513(None)
groups=544(Administrators),545(Users)
>
> From cron
> uid=500(Administrator) gid=513(None) groups=513(None),545(Users)
>
> The groups are different.  Why is that?

Sorry, I don't know.  Is your /etc/passwd and /etc/group files set up
correctly?  Is cron really switching users correctly?

BTW, I get the following:

    $ id
    uid=19695(jt) gid=10513(Domain Users)
groups=544(Administrators),545(Users),10513(Domain Users)

    $ cat /tmp/id.txt
    uid=19695(jt) gid=10513(Domain Users)
groups=544(Administrators),545(Users),10513(Domain Users)

Sounds like your Cygwin setup is not correct.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6


How do I encrypt a field in postgresql?

From
"Jeff Lu"
Date:
Can someone show me how to encrypt/decrypt a field through C function
call?

Thanks
-jeff