根据进程信息加开机自动启动的脚本
#!/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