Created
May 16, 2018 14:16
-
-
Save gustavoapolinario/896c1b8ce1c24dce8acb1d901c26ddc3 to your computer and use it in GitHub Desktop.
Script sh to clear logs by time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#not tested... not working. | |
compacta() { | |
find $1 -name "*-201" -not -path "*.tar.gz" -exec tar -zcvf {}.tar.gz {} \; | |
} | |
remove_olders() { | |
find $1* -mtime +7 -exec rm {} \; | |
} | |
clear() { | |
remove_olders $1-* | |
} | |
clear /var/log/cron | |
clear /var/log/maillog | |
clear /var/log/mysqld.log | |
clear /var/log/secure | |
clear /var/log/spooler | |
clear /var/log/yum.log | |
clear /var/log/mysql/error.log | |
clear /var/log/mysql/mysql-slow.log | |
clear /var/log/httpd/access_log | |
clear /var/log/httpd/error_log | |
#compacta /var/log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment