I've recently wanted to run a different archive_command during database shutdown than during normal operations. In particular, if the normal archive process fails during normal operations, I want it to be retried later (as it currently does). But if it fails during shutdown, I want it to run a fallback archive_command.
What version of PostgreSQL are you using?
The only way I can see to accomplish this is to have the archive_command try to connect back to the database and see if it gets an error. That seems pretty ugly. Is there a better way?
What's your goal here?
During a shutdown, if you don't so much care about checkpoint and fsync of buffers to disk, you can do an immediate shutdown.