更改为345 98 10
我有以下脚本
#!/bin/sh
# chkconfig: 345 99 01
# description: some startup script
### BEGIN INIT INFO
# Provides: weblogic
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop OurDB
# Description: OurDB is a very fast and reliable database
# engine used for illustrating init scripts
### END INIT INFO
. /etc/rc.d/init.d/function
service=startWebLogic.sh
user=*******
password=******
dbschemaname=******
hostname=*******
port=********
weblogic_start()
{
pgrep -f startWebLogic.sh > /dev/null
if ! [ $? -eq 0 ]; then
echo "exit" | sqlplus -L "$user/$password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=$hostname)(Port=$port))(CONNECT_DATA=(SID=$dbschemaname)))" | grep "Connected to" > /dev/null
if [ $? -eq 0 ]; then
/home/usr/Oracle/Middleware/Oracle_Home/user_projects/domains/bin/startWebLogic.sh &
else
echo "WARNING! No connection to the Oracle Server" | mail -s OracleServerDown monitoring@accedia.com
fi
else
echo "WARNING! Running WebLogic service was found!" | mail -s "Service Already Running" monitoring@example.com
fi
}
weblogic_stop()
{
pgrep -f startWebLogic.sh > /dev/null
if [ $? -eq 0 ]; then
/home/usr/Oracle/Middleware/Oracle_Home/user_projects/domains/Econt/bin/stopWebLogic.sh & pid=$! ; sleep 5m; pkill -TERM -P $pid
ps -ef| grep $pid
if [ $? -ne 0 ];then
pkill -TERM -P $pid
fi
pid=`ps -ejH|grep "startWebLogic" | grep -iv "grep" | awk '{print $1}'`
pkill -TERM -P $pid
else
echo "WARNING! No running WebLogic service was found" | mail -s "WebLogic Not Found" monitoring@example.com
fi
}
case $1 in
start)
weblogic_start
;;
stop)
weblogic_stop
;;
*) echo "Invalid input"
;;
esac
我已经正确地将其放在init.d和其他内容中,chmod-ed正确地将其放入rc.local中,又不想启动启动,尽管如果我手动运行它,请通过争论,例如。" Service Weblogic Start"它可以正常工作,无论是根还是不奏效。任何人都有任何建议,为什么会这样做,并且有任何解决方案吗?
您不需要将其放入init.d
和rc.local
两个地方。一个就足够了。
将其放入 init.d
:
对于基于Debian的OS:
sudo update-rc.d script_name defaults
centos:
chkconfig --add myscript
找到了一个解决方案,问题是优先级,我已将ChkConfig选项从345 9901。