PostgreSQL vacuum in cron

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications PostgreSQL vacuum in cron
# 1  
Old 10-11-2011
PostgreSQL vacuum in cron

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

thanks.
# 2  
Old 10-11-2011
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
# 3  
Old 10-11-2011
but I've redirected cronjob to > /dev/null 2>&1 because email is not configured/not running

here is the script:
Code:
#! /bin/sh

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

# 4  
Old 10-11-2011
Well, then there won't be any error messages anywhere. Redirect to a file instead of /dev/null instead.
# 5  
Old 10-11-2011
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.
# 6  
Old 10-11-2011
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
# 7  
Old 10-12-2011
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?
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question