I have streaming replication setup on 2 Postgres 9.1 servers. Everything is ok apart from the archivecleanup. In the logs it says:

sh: 1: pg_archivecleanup: not found
2013-11-19 09:17:37 GMT WARNING:  archive_cleanup_command "pg_archivecleanup /var/lib   /postgresql/9.1/wals/ %r": return code 32512

I can see pg_archivecleanup is in /usr/lib/postgresql/9.1/bin. Why can Postgres not see this?


If you're using Postgres 9.1's streaming replication why do you need archive cleanups?

I suggest the following alternative to your entire situation:

  1. Set your log segment retention to something sensible.
    A good starting point for "sensible" would be to set wal_keep_segments to keep roughly the same number of log segments as you were previously keeping in the master's archive.
    You can adjust from there as needed.

  2. Turn off archive_mode on your servers.
    Streaming replication obviates the need for this, and (1) above means you'll have plenty of log segments to restore from if you need to.

  3. Get rid of the pg_archivecleanup command in recovery.conf on your slaves.
    (Because you simply don't need it with streaming replication.)

Depending on your environment you may elect to leave out (2) (if you have a real need for the WAL archive other than replication), but in most cases you only had that archive around so you could do replication/log-shipping anyway. Save yourself the disk I/O.


/usr/lib/postgresql/9.1/bin is probably not in your path. I suggest you put the full path in your configuration file.

  • Sorry for the delayed response. Yes, /usr/lib/postgresql/9.1/bin is in my PATH. And if I try to run pg_cleanup, it is found. – JKK Dec 10 '13 at 12:55
  • @JKK, It may be in your path, but is it in the path of the user running the script containing pg_archivecleanup (maybe postgres)? What happens when you just specify the full path to pg_archivecleanup in the conf file? – Mark Berry Jun 18 '14 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.