知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

根据进程信息加开机自动启动的脚本

发布时间:2014-09-05 15:38:51作者:知识屋


根据进程信息加开机自动启动的脚本
 
#!/bin/bash  www.zhishiwu.com  
 
addchkconfig()
{
if [[ `chkconfig --list|grep $1` ]]
then echo ---already in $1
chkconfig --list|grep $1
else echo ---not already in $1
        if [[ `ls -l /etc/init.d/$1` ]]
        then echo ---add 
        chkconfig --add $1
        chkconfig --list $1
        else
        echo no $1  in init.d
        fi
fi
}
 
ps -efjH|awk ' $5 != 1 { print $0 }'|grep -vE "mingetty|sshd|zabbix|/home/script/| sleep |nrpe|udevd|syslogd|klogd|irqbalance|snmpd|agetty|ps -ef|crond|grep|awk|iostat|netstat|sendmail|iscsi|xinetd"|awk '{print $10,$11}'|grep -v CMD > /tmp/tmpforcron
cat /tmp/tmpforcron
ps -efjH|awk ' $5 != 1 { print $0 }'|grep -vE "mingetty|sshd|zabbix|/home/script/| sleep |nrpe|udevd|syslogd|klogd|irqbalance|snmpd|agetty|ps -ef|crond|grep|awk|iostat|netstat|sendmail|iscsi|xinetd"
echo '--------------end-----info------'
 
date=`date +%Y%m%d:%H%M%S`
cp /etc/rc.local /tmp/rc.local.bak.$date
#cp /tmp/rc.local /tmp/rc.local.bak.$date
ls -l /tmp/rc*
echo pause read
read
 
while read v1 
do
 
if [[ `echo $v1|grep home `  ]]
then echo $v1
cat tmpforcron|grep $v1 -B1 > /tmp/tmpforcronrclocal
echo ---rc
filepath=`tail -1 /tmp/tmpforcronrclocal`
echo "cd  `dirname $filepath` && `head -1 /tmp/tmpforcronrclocal` " >> /etc/rc.local
diff /etc/rc.local /tmp/rc.local.bak.$date
#diff /tmp/rc.local /tmp/rc.local.bak.$date
cat /etc/rc.local
echo ---rcend
else echo -------not  $v1
fi
 
if [[ `echo $v1|grep mysql` ]]
then
        addchkconfig  mysqld
fi
 
if [[ `echo $v1|grep http` ]]
then    
        addchkconfig  httpd
fi
 
done  < /tmp/tmpforcron
 
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜