Operating System - HP-UX
1833748 Members
2773 Online
110063 Solutions
New Discussion

Shutdown of cache database not being completed

 
wayne_104
Regular Advisor

Shutdown of cache database not being completed

Hi

I have the shutdown script of my cache database in rc2.d as Kcache950

This is a link to a script in /sbin/init.d

#!/bin/sh
set -x
#
# /etc/rc.d/init.d/cache
# Cashier Control Script
#
# chkconfig: 2345 55 01
# description: Cache DB service
#


RETVAL=0
CACHE_USR="cacheusr"

case "$1" in
start)
echo -n ""
echo "Starting cache:"
echo $PATH
/usr/bin/su - $CACHE_USR -c "/home/cacheusr/cache_start.sh"
RETVAL=0
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/cache
;;
stop)
echo -n "Stopping cache: "
/usr/bin/su - $CACHE_USR -c "/home/cacheusr/cache_stop.sh &"
CHILD_PID=${!}
wait ${CHILD_PID} # parent will wait until child finishes

RETVAL=0
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/cache
;;
restart)
stop
start
;;
*)
echo "usage: $0 (start|stop|restart|help)"
esac
cache: END

however hp ux does not wait for this script to complete before shuting down so the database crashes.

Why???
9 REPLIES 9
Earl_Crowder
Trusted Contributor

Re: Shutdown of cache database not being completed

Well, the "su - $CACHE_USER" spawns a new shell, which in turn backgrounds the cache_stop.sh, and then exits. The parent shell doesn't know that the child shell spawned a process in the background.

You could change it to not background the cache_stop.sh, and remove the CHILD_PID assignment and the call to wait.

Also, you can remove the "-n" from the echo commands.
Zinky
Honored Contributor

Re: Shutdown of cache database not being completed

Looks like the above is for Linux sir.

It should still technically work... the /var/lock scheme I don;t think is available in HP-UX.

So drop & in :

/usr/bin/su - $CACHE_USR -c "/home/cacheusr/cache_stop.sh &"

Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
wayne_104
Regular Advisor

Re: Shutdown of cache database not being completed

Hi Guys thanks for that.

The /usr/bin/su - $CACHE_USR -c "/home/cacheusr/cache_stop.sh &"
CHILD_PID=${!}
wait ${CHILD_PID} # parent will wait until child finishes
was suggested as my shutdown of the db does not complete before the system goes down.

it gets as far as the messages below.

01/13/11-07:58:24:862 (14349) 0 Receive daemon exited due to SIGTERM received
01/13/11-07:58:24:862 (14369) 0 Application Monitor exited due to SIGTERM receiv
ed


During a shutdown it should end with cahe shutdown complete message.

which if i do it manualy is the case.

And when i bring up the db it says it is fine.

However when i do a reboot it does not and starting the db states it is recovering from a crash.
Zinky
Honored Contributor

Re: Shutdown of cache database not being completed

Have you tried removing the & and the wait?
Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
wayne_104
Regular Advisor

Re: Shutdown of cache database not being completed

yip i have with the same reult
Earl_Crowder
Trusted Contributor

Re: Shutdown of cache database not being completed

Well then sounds like the cache_stop.sh script isn't waiting for the database to be shut down cleanly before it finishes.

Might be best to modify the cache_stop.sh to actually wait for the shutdown to complete before exiting?

Zinky
Honored Contributor

Re: Shutdown of cache database not being completed

Or check if cache_stop.sh has a background spec in whatever binary or script it calls?

Or even add a looper there to check if the software has actually stopped?
Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
RickT_1
Valued Contributor

Re: Shutdown of cache database not being completed

How are you rebooting, what command? Reboot?

According to the manual:

WARNINGS
reboot does not invoke the shutdown scripts associated with subsystems to bring them down in a cautious
manner. See shutdown(1M).

If you want your shutdown scripts to work you need to use shutdown.


Rick
wayne_104
Regular Advisor

Re: Shutdown of cache database not being completed

Rick you are the man thanks.