Skip to content

Instantly share code, notes, and snippets.

@edib
Last active February 6, 2022 11:14
Show Gist options
  • Save edib/d277d5942b2ef077b434085903df0507 to your computer and use it in GitHub Desktop.
Save edib/d277d5942b2ef077b434085903df0507 to your computer and use it in GitHub Desktop.
postgres logs compress script
#!/bin/bash
echo "Job Started!" >> "log.compress.log" 2>&1
echo `date` >> "log.compress.log" 2>&1
find "/var/lib/pgsql/9.6/data/pg_log/" -type f -name "*.log" -mtime +1 | while read file ; do gzip -v $file >> "log.compress.log" 2>&1 ; done
echo `date` >> "log.compress.log" 2>&1
echo "Job Finished!" >> "log.compress.log" 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment