Close to the CentOS 6 system optimization script above, because sometimes a virtual machine has already brushed the optimization script, but perhaps for other reasons, the virtual machine is temporarily on hold. After a period of time, suddenly have to use and do not know whether the virtual machine has been optimized, and re-use cobbler brush once the system will take some time, so the detection system has brushed the optimization script shell script is born. The script is not particularly accurate, but can be a check for the last optimization script, if the script has been brushed, it will run the script to know that the system has been optimized, can immediately put into use, to avoid wasting time to re-brush the system again. If it is a fully reinstalled CentOS 6.x, then the result can be seen that the virtual machine is not optimized, then perform optimization script optimization once.
#!/bin/bash##################################################################################### #The Script is used to check whether the optimize script had been run on centos 6.x#created by jerry12356 on may 16th, 2016## ###################################################################################. /etc/init.d/ Functionscheck_iptables () { /etc/init.d/iptables status >/dev/ null 2>&1 [ $? -ne 0 ] && action "Optimize iptables: " /bin/true | | action "optimize iptables: " /bin/false}check_selinux () { selinux_status= ' Getenforce ' [ $selinux _status == ' Disabled ' ] && action "optimize selinux: " /bin/true | | action "Optimize selinux: " /bin/false}check_addusers () { egrep " admin|nginx| Zabbix " /ETC/PASSWD  >>/DEV/NULL 2>&1 [ $? -EQ 0 ] && action "add users: " /bin/true | | action "add users: " /bin/false}check_install () { rpm -qa|egrep "gcc|gcc-c++|openssh-clients|wget|make|cmake|curl|finger|nmap|tcp_wrappers|expect|lrzsz| Unzip|zip|xz|ntpdate|lsof|telnet|vim|tree " >/dev/null 2>&1 [ $? -eq 0 ] && action "install softwares: " /bin/true | | action "install softwares: " /bin/false}check_repos () { [ -d /etc/yum.repos.d/bak ] && action "Update repos: " / bin/true | | action "update repos: " &NBsp;/bin/false }check_time () { date -r |grep +0800 >/ dev/null 2>&1 [ $? -eq 0 ] && action "Setting timezone: " /bin/true | | action "setting timezone: " /bin/false crond_num= ' Crontab -l|grep ntpdate|wc -l ' [ $crond _num -ge 1 ] && action "sync time: " /bin/true | | action "sync time: " /bin/false }check_services () { service_num= ' chkconfig --list |grep 3:on|egrep "crond|network|rsyslog|sshd" |wc -L ' [ $service _num -eq 4 ] && action "optimize services: " /bin/true | | action "optimize services: " /bin/false} check_history () { & nbsp; [ $HISTSIZE -eq 10000 ] && action "Setting history: " /bin/true | | action "setting history: " /bin/false} check_kernel () { conn_num= ' ulimit -n ' [ $conn _num -eq 2097152 ] && action "optimize kernel: " /bin/true | | action "optimize kernel: " /bin/false} check_hostname () { [ $HOSTNAME != ' localhost.localdomain ' ] && action ' change hostname: " /bin/true | | action "change hostname: " /bin/false} check_iptablescheck_ Selinuxcheck_adduserscheck_installcheck_reposcheck_timecheck_servicescheck_historycheck_kernelcheck_hostname
This article is from "it Little two lang" blog, please make sure to keep this source http://jerry12356.blog.51cto.com/4308715/1839284
CentOS 6 System Optimization test script