On Mon, Jan 2, 2012 at 7:04 PM, David E. Wheeler <david@justatheory.com> wrote:
> On Dec 20, 2011, at 6:00 PM, David E. Wheeler wrote:
>
>>> Oh, OK. We use popen() to execute the task on *nix, and that only
>>> reads STDOUT, so you should handle redirection in your script. I did
>>> spend some time look at this a few years back as I recall, and didn't
>>> find a fix I was happy with.
>>
>> So it will pick up the output to STDOUT? That’s fine, I think I can tweak the scripts to send STDERR to STDOUT.
>
> Unfortunately, it does not seem to work. I have pgagent started like so:
>
> pgagent -s /var/log/pgagent_91.log hostaddr=127.0.0.1 dbname=postgres user=postgres
You need to increase the log level, eg.
pgagent -l DEBUG2 -s /var/log/pgagent_91.log hostaddr=127.0.0.1
dbname=postgres user=postgres
> /var/log/pgagent_91.log does exist, and has nothing in it at all.
>
> So I created this shell script:
>
> #!/bin/bash
>
> echo Hi there
> perl -e 'die "WTF!"' || exit $? 2>&1
>
> I set up a job to run it. The results were:
>
> postgres=# select * from pgagent.pga_jobsteplog where jsljlgid = 46;
> -[ RECORD 1 ]------------------------------
> jslid | 45
> jsljlgid | 46
> jsljstid | 13
> jslstatus | f
> jslresult | -1
> jslstart | 2012-01-02 10:59:32.606959-08
> jslduration | 00:00:00.01009
> jsloutput | Hi there
> | WTF! at -e line 1.
> |
>
> Which is great. However, the /var/log/pgagent_91.log file is still empty. Should I take that to mean that job output
isnot logged there, but only errors from pgagent itself?
Yes, it's really just a debug log.
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company