3

[Linux笔记]Linux一键清空日志

写了个Linux一键清空日志的批量脚本,复制下面的内容保存为一个bash脚本文件,执行就可以清除常见的Linux日志文件了。方便使用,总会有用到的时候,可以适当的添加要清空的对象。

#!/bin/sh
cat /dev/null > /var/run/utmp
cat /dev/null > /var/log/lastlog
cat /dev/null > /var/log/syslog
cat /dev/null > /var/log/messages
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/openwebmail.log
cat /dev/null > /var/log/secure
cat /dev/null > /var/log/xferlog
cat /dev/null > /var/log/auth.log
cat /dev/null > /var/log/yum.log
cat /dev/null > /var/log/brcm-iscsi.log
cat /dev/null > /var/log/btmp
cat /dev/null > /var/log/cron
cat /dev/null > /var/log/dmesg
cat /dev/null > /var/log/faillog
cat /dev/null > /var/log/anaconda.log
cat /dev/null > /var/log/anaconda.syslog
cat /dev/null > /var/log/anaconda.xlog
cat /dev/null > /etc/httpd/logs/access_log
cat /dev/null > /etc/httpd/logs/error_log
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/anaconda.log
cat /dev/null > /var/log/auth.log
cat /dev/null > /var/log/boot.log
cat /dev/null > /var/log/brcm-iscsi.log
cat /dev/null > /var/log/php-fpm.log
cat /dev/null > /var/log/pureftpd.log
cat /dev/null > /var/log/scrollkeeper.log
cat /dev/null > /var/log/yum.log
cat /dev/null > /var/log/httpd/access_log
cat /dev/null > /var/log/httpd/access.log
cat /dev/null > /var/log/httpd/error_log
cat /dev/null > /var/log/httpd/error.log
cat /dev/null > /var/log/httpd/ssl_error_log
cat /dev/null > /var/log/httpd/ssl_request_log
cat /dev/null > /var/log/httpd/ssl_access_log
cat /dev/null > /usr/local/apache_LuManager/logs/access_log
cat /dev/null > /usr/local/apache_LuManager/logs/error_log
cat /dev/null > /usr/local/apache/logs/access_log
cat /dev/null > /usr/local/apache/logs/error_log
cat /dev/null > /usr/local/apache/logs/IP-access_log
cat /dev/null > /usr/local/apache/logs/IP-error_log
cat /dev/null > /usr/local/apache/logs/IP-access_log
cat /dev/null > /usr/local/apache/logs/IP-error_log
cat /dev/null > /usr/local/apache/logs/access_log
cat /dev/null > /usr/local/apache/logs/error_log
cat /dev/null > /usr/local/nginx/logs/access.log
cat /dev/null > /usr/local/nginx/logs/error.log
cat /dev/null > /var/log/lighttpd/lighttpd.error.log
cat /dev/null > /var/log/lighttpd/lighttpd.access.log
cat /dev/null > /var/www/logs/access_log
cat /dev/null > /var/www/logs/access.log
cat /dev/null > /var/www/logs/error_log
cat /dev/null > /var/www/logs/error.log
cat /dev/null > /home/wwwlogs/access.log
cat /dev/null > /home/wwwlogs/error.log
cat /dev/null > /home/pgsql_data/pgsql.log
cat /dev/null > /opt/software/openvpn-2.0.9/easy-rsa/keys/openvpn-status.log
history -c
cat /dev/null > /root/.bash_history
exit

3 Comments

发表评论

电子邮件地址不会被公开。 必填项已用*标注