Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.43 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. limit=20971520                        # 20 gygabytes
  4. batchsize=200                         # files to remove by one circle
  5. walpath="/var/lib/pgsql/pgLogs"  # wal archive path
  6.  
  7. # cut archive while size is greater than limit
  8. while [ "$(du -s "${walpath}" | cut -f 1)" -gt "${limit}" ]; do
  9.     echo Remove old WAL
  10.     ls -lhtr ${walpath}/ | head -n ${batchsize} | awk '{print $9}' | xargs -I {} rm -v ${walpath}/{}
  11. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement