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


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Application Script didn't run during AIX shutdown using RC directories
# 1  
Old 08-23-2018
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"

Code:
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


Code:
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"

Code:
-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"
Code:
-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.
This User Gave Thanks to System Admin 77 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Run an application in shell script

I run the following command using the command line. I need to run the same command in shell script : ./sas.server start start is a parameter that passes to start.server to startup services within start.server. the path to sas.server is /path/Lev1 Here is my code: #!/bin/sh set... (3 Replies)
Discussion started by: dellanicholson
3 Replies

2. Red Hat

Script to run at start and shutdown

Hello, I have script that start and shutdown the application. where should i place my script so that it can execute at my OS shutdown ? Pls help me... (2 Replies)
Discussion started by: saurabh84g
2 Replies

3. Shell Programming and Scripting

How to run perl script on multiple files of two directories?

Hi I have 100 files under file A labled 1.txt 2.txt.....100.txt(made up name) I have 1 files under file B labled name.txt How can i run the same perl script on 100 files and file name.txt I want to run perl script.pl A/1.txt B/name.txt perl script.pl A/2.txt B/name.txt ....... perl... (3 Replies)
Discussion started by: grace_shen
3 Replies

4. Shell Programming and Scripting

How to run perl script in remote machine from java application?

Hi I am working in a java application. I need to execute a perl script(linux) which is in remote machine in java application from local machine(windows). I need to do this process automatically that is without manual intereption. Now I will explain the process clearly, at present to run the... (1 Reply)
Discussion started by: bassma
1 Replies

5. UNIX for Dummies Questions & Answers

emulate aix 5.3 , how ....? pearpc didn't work

how to emulate aix 5.3 i had try pearpc , but it didn't work ... someone have some solution? thanks (1 Reply)
Discussion started by: prpkrk
1 Replies

6. AIX

My script didn't run every run every minute at cronjob

In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all. * * * * * script.sh When I run it manually, I can run it. Is that anything wrong with the above line? If I change it to something like below,... (4 Replies)
Discussion started by: ngaisteve1
4 Replies

7. Shell Programming and Scripting

Run perl script on files in multiple directories

Hi, I want to run a Perl script on multiple files, with same name ("Data.txt") but in different directories (eg : 2010_06_09_A/Data.txt, 2010_06_09_B/Data.txt). I know how to run this perl script on files in the same directory like: for $i in *.txt do perl myscript.pl $i > $i.new... (8 Replies)
Discussion started by: ad23
8 Replies

8. AIX

stop application befor shutdown

Stop the application before shutdown the server .. I have application need to be started with the system and also need to be stop before shutdown the system This is the path of the application: /usr/appstart /usr/appstop to start the application with the startup of the... (2 Replies)
Discussion started by: Mr.AIX
2 Replies

9. Programming

Application Cleanup during Linux Shutdown

I'm trying to do some cleanup (write open files) when Linux shuts down. I thought the right method would be to trap SIGTERM and do the necessary processing. Here's my sample code: #include <stdio.h> // for File I/O #include <signal.h> // for signals #include <unistd.h> // for sleep() void... (6 Replies)
Discussion started by: whatisron
6 Replies

10. Shell Programming and Scripting

run a application from a remote server via script?

I have a ksh script that does a bunch of things, then runs telnet server_b I then manually login, manually run one command (which launches an application with display back to my workstation), then logout at which point the main script takes back over, runs something else, then ends. Is... (4 Replies)
Discussion started by: yankee428
4 Replies
Login or Register to Ask a Question

Featured Tech Videos