[root@ns ~]# vim /etc/init.d/sybased
插入以下内容:
#!/bin/bash
#
# chkconfig: 2345 81 31
# description: sybase start&stop script
# Source function library.
. /etc/rc.d/init.d/functions
SYB_OWNER=sybase
SYBASE=/opt/sybase
SYBASE_ASE=ASE-15_0
SYBASE_OCS=OCS-15_0
SYBASEDIR=$SYBASE/$SYBASE_ASE/install
SYB_STOP=$SYBASE/$SYBASE_OCS/bin
SAPASS=123456
DSQUERY=testb2bjoy
DATASERVER=testb2bjoy
RETVAL=0
PATH=$SYBASE/$SYBASE_ASE/bin:/$SYBASE/$SYBASE_ASE/install:/$SYBASE/$SYBASE_OCS/binPATHHOME/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/bin:.
export SYBASE DSQUERY SYBASE_ASE SYBASE_OCS DATASERVER SYBASEDIR PATH
if [ ! -f $SYBASE/$SYBASE_ASE/install/startserver ]
then
echo "Sybase startup: startserver not found"
exit
fi
start()
{
su - $SYB_OWNER -c "$SYBASE/$SYBASE_ASE/install/startserver -f $SYBASEDIR/RUN_"$DATASERVER""
sleep 60
su - $SYB_OWNER -c "$SYBASE/$SYBASE_ASE/install/startserver -f $SYBASEDIR/RUN_"$DATASERVER"_bs"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
action $"Starting Sybase 12.5 startserver: " /bin/true
else
action $"Starting Sybase 12.5 startserver: " /bin/false
fi
return $RETVAL
}
stop()
{
su - $SYB_OWNER -c "isql -Usa -P$SAPASS -S$DATASERVER -i$SYBASE/$SYBASE_ASE/install/shutdown_backup.sql"
su - $SYB_OWNER -c "isql -Usa -P$SAPASS -S$DATASERVER -i$SYBASE/$SYBASE_ASE/install/shutdown_dataserver.sql"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
action $"Stopping Sybase 12.5 sybshutdown: " /bin/true
else
action $"Stopping Sybase 12.5 sybshutdown: " /bin/false
RETVAL=1
fi
return $RETVAL
}
restart()
{
stop
start
}
pid="dataserver"
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
status)
su - sybase -c "/opt/sybase/ASE-15_0/install/showserver"
RETVAL=$?
;;
restart)
restart
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|status|stop|restart}"
exit 1
esac
exit $RETVAL
[root@ns ~]# chmod 777 /etc/init.d/sybased
[root@ns ~]# chkconfig add sybased
[root@ns ~]# chkconfig --list |grep sybased
插入以下内容:
#!/bin/bash
#
# chkconfig: 2345 81 31
# description: sybase start&stop script
# Source function library.
. /etc/rc.d/init.d/functions
SYB_OWNER=sybase
SYBASE=/opt/sybase
SYBASE_ASE=ASE-15_0
SYBASE_OCS=OCS-15_0
SYBASEDIR=$SYBASE/$SYBASE_ASE/install
SYB_STOP=$SYBASE/$SYBASE_OCS/bin
SAPASS=123456
DSQUERY=testb2bjoy
DATASERVER=testb2bjoy
RETVAL=0
PATH=$SYBASE/$SYBASE_ASE/bin:/$SYBASE/$SYBASE_ASE/install:/$SYBASE/$SYBASE_OCS/binPATHHOME/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/bin:.
export SYBASE DSQUERY SYBASE_ASE SYBASE_OCS DATASERVER SYBASEDIR PATH
if [ ! -f $SYBASE/$SYBASE_ASE/install/startserver ]
then
echo "Sybase startup: startserver not found"
exit
fi
start()
{
su - $SYB_OWNER -c "$SYBASE/$SYBASE_ASE/install/startserver -f $SYBASEDIR/RUN_"$DATASERVER""
sleep 60
su - $SYB_OWNER -c "$SYBASE/$SYBASE_ASE/install/startserver -f $SYBASEDIR/RUN_"$DATASERVER"_bs"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
action $"Starting Sybase 12.5 startserver: " /bin/true
else
action $"Starting Sybase 12.5 startserver: " /bin/false
fi
return $RETVAL
}
stop()
{
su - $SYB_OWNER -c "isql -Usa -P$SAPASS -S$DATASERVER -i$SYBASE/$SYBASE_ASE/install/shutdown_backup.sql"
su - $SYB_OWNER -c "isql -Usa -P$SAPASS -S$DATASERVER -i$SYBASE/$SYBASE_ASE/install/shutdown_dataserver.sql"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
action $"Stopping Sybase 12.5 sybshutdown: " /bin/true
else
action $"Stopping Sybase 12.5 sybshutdown: " /bin/false
RETVAL=1
fi
return $RETVAL
}
restart()
{
stop
start
}
pid="dataserver"
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
status)
su - sybase -c "/opt/sybase/ASE-15_0/install/showserver"
RETVAL=$?
;;
restart)
restart
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|status|stop|restart}"
exit 1
esac
exit $RETVAL
[root@ns ~]# chmod 777 /etc/init.d/sybased
[root@ns ~]# chkconfig add sybased
[root@ns ~]# chkconfig --list |grep sybased
编辑回复