Parameter · Write-Ahead Log / Archive Recovery
archive_cleanup_command
Sets the shell command that will be executed at every restart point.
- Default:
'' (empty) - Type: string
- Applies: Reload
In plain words
A standby that reads WAL from a shared archive could leave that archive growing forever. archive_cleanup_command runs at every restartpoint and gets %r, the oldest WAL file still needed, so a tool like pg_archivecleanup can delete older files.
For DBAs and operators
Typical value: archive_cleanup_command = 'pg_archivecleanup /mnt/standby_archive %r'. A restartpoint is the standby's version of a checkpoint (driven by checkpoint_timeout / max_wal_size and the primary's checkpoint records). Errors are logged as warnings but do not stop recovery.
Only use it when the archive is dedicated to this standby. If the same archive serves PITR backups or other standbys, deleting files there destroys your recovery window. Backup tools usually manage retention themselves.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().
See it in context
Archiving and point-in-time recovery Startup process Checkpointer