PostgreSQL vacuum in cron

I'm running vacuum for PostgreSQL with a script in cronjob. How to check if there were errors?

thanks.

If there is unhandled output, then it will be e-mailed to the user running the cron job. This will be a unix mail, so probably it will stay on the server running the request rather than route off to a Windows based mail service.

If you have handled the output by putting it in a file somewhere, then you need to read it and interpret any messages. What does your code look like?

Robin
Liverpool/Blackburn
UK

but I've redirected cronjob to > /dev/null 2>&1 because email is not configured/not running

here is the script:

#! /bin/sh

/usr/local/pgsql/bin/vacuumdb   -z -d edb -U postgres
eventremover.sh

Well, then there won't be any error messages anywhere. Redirect to a file instead of /dev/null instead.

I see. should I use the '-v' option for vacuumdb to catch errors?

as it is, it has never output anything other than 'VACUUM'.
but, presumably, there were no errors.

Aside from redirecting stderr to a file, your script can check vacuumdb's exit status. With respect to documenting its exit status, vacuumdb's manual page is utterly useless. However, a quick peek at the code shows that it returns 0 when successful and 1 when an error has occurred. Testing for non-zero exit status would be the most definitive way to determine that something unexpected has occurred.

http://doxygen.postgresql.org/vacuumdb\_8c_source.html

Regards,
Alister

ok, thanks all.
btw, how does exit status work in scripts? if one command in script returns nonzero, will the whole script give error status?
or do we need to include command at bottom of script that 'makes' status?