Application Script didn't run during AIX shutdown using RC directories

Hi,

I am trying to bring down the application gracefully before bringing down AIX OS/LPAR using RC directories.

Issue: Application script is not working properly during/before AIX OS/LPAR shutdown. looks like "rc.d" directories doesn't recognize Kill script.

But Startup script (using rc2.d) is working as expected. When UI reboot the LPAR, as part of "/etc/rc.d/ec2.d/S80app" app script ran in run level 2.

What I have done so far

under "/etc/rc.d"

drwxr-xr-x    2 root     system          256 Apr 18 2015  rc9.d
drwxr-xr-x    2 root     system          256 Apr 18 2015  rc8.d
drwxr-xr-x    2 root     system          256 Apr 18 2015  rc7.d
drwxr-xr-x    2 root     system          256 Apr 18 2015  rc5.d
drwxr-xr-x    2 root     system          256 Apr 18 2015 rc4.d
drwxr-xr-x    2 root     system          256 Jun 13 2017  rc3.d
-r-xr--r--    1 root     system         1610 Jun 13 2017  rc
drwxr-xr-x    2 root     system          256 Aug 22 14:04 init.d
drwxr-xr-x    2 root     system          256 Aug 22 14:36 rc6.d
drwxr-xr-x    2 root     system          256 Aug 22 14:47 rc2.d

Created a common script under "/etc/rc.d/init.d/"

app.sh

cat app.sh
#!/bin/ksh
# description: APP startup script

case "$1" in
start )
        /opt/test/mydir/start.sh
        ;;

stop  )
        /opt/test/mydir/stop.sh
        ;;

* )
        echo "Usage: $0 {start|stop}"
        exit 1
esac
[root@test1]/etc/rc.d/rc2.d>

Scenario 1)

Then
created the symbolic links under "/etc/rc.d/rc2.d"

-r-xr-xr-x    1 root     system          326 Jun 13 2017  Ssshd
-r-xr-xr-x    1 root     system          325 Jun 13 2017  Ksshd
-r-x------    1 root     system         2545 Jun 13 2017  Kwpars
-rwxr-xr-x    1 root     system          175 Jun 13 2017  S00ct_boot

lrwxrwxrwx    1 root     system           24 Aug 22 14:36 S80app7 -> /etc/rc.d/init.d/app.sh
lrwxrwxrwx    1 root     system           24 Aug 22 14:47 K90app7 -> /etc/rc.d/init.d/app.sh

Result: Not as expected
LPAR was shutdown; stop script ran successfully before shutdown.
But Issue is stop script ran again during LPAR activation/restart as well.

My intention is only to run stop script before shutdown and start script after the lpar restart.

Scenario 2)

under "/etc/rc.d/rc2.d"

-r-xr-xr-x    1 root     system          326 Jun 13 2017  Ssshd
-r-xr-xr-x    1 root     system          325 Jun 13 2017  Ksshd
-r-x------    1 root     system         2545 Jun 13 2017  Kwpars
-rwxr-xr-x    1 root     system          175 Jun 13 2017  S00ct_boot

lrwxrwxrwx    1 root     system           24 Aug 22 14:36 S25app7 -> /etc/rc.d/init.d/app.sh

and
after reading IBM tech note (ref to step 5 in IBM tech note)

IBM Starting and Stopping Software via System V RC Directories - United States

under "/etc/rc.d/rc6.d"
ln -s /etc/rc.d/init.d/app7.sh K70app7

Result: Stop script was not even ran.

even created a directory rc0.d

"/etc/rc.d/rc0.d"
and created symmlink

ln -s /etc/rc.d/init.d/app7.sh K70app7

Result: Stop script was not even ran.

Could you help me fix this issue. I am not sure If am missing anything.

Thank you.

------ Post updated at 03:20 PM ------

update: app7 or app (please ignore those in the post);

But I am using app7 across all places. So its not naming or typo issue.

------ Post updated 08-23-18 at 09:51 AM ------

Update:

Issue has been resolved.
Using /etc/inittab for startup and /etc/rc.shutdown for Shutdown.

------ Post updated at 09:53 AM ------

closing the thread.

1 Like