Let me elaborate on this strange subject line :)
I have created two symbolic links in /etc/rc.d/rc2.d directory that should start and stop my application during boot-up and shutdown respectively:
#ls -l /etc/rc.d/rc2.d/*enigma
lrwxrwxrwx 1 root system 19 May 19 10:13 /etc/rc.d/rc2.d/K30enigma -> ../init.d/enigma.sh
lrwxrwxrwx 1 root system 19 May 19 09:42 /etc/rc.d/rc2.d/S30enigma -> ../init.d/enigma.sh
#
enigma.sh script is very simple:
#!/bin/sh
##################################################
# name: enigma.sh
# purpose: start or stop the enigma agent
##################################################
[ -f /apps/enigma/Start.sh ] && [ -f /apps/enigma/Stop.sh ] || exit 0
case "$1" in
start)
sudo -u enigma -i /apps/enigma/Start.sh
;;
stop)
sudo -u enigma -i /apps/enigma/Stop.sh
;;
*)
echo "Usage: $0 (start | stop)"
exit 1
esac
Start.sh and Stop.sh scripts currently only write text about starting and stopping an application in a log file:
#cat /apps/enigma/Start.sh
#!/bin/sh
echo "enigma started at $(date)">>/var/log/enigma
#cat /apps/enigma/Stop.sh
#!/bin/sh
echo "enigma stopped at $(date)">>/var/log/enigma
#
Why do I think that init behavior is strange?
When I reboot a server, what I expected to see in the log file first was message about stopping the application before reboot and message about starting the application after reboot.
What happens is that the application is stopped before reboot, then firstly stopped and then started after reboot!
Log file clearly shows this:
#tail /var/log/enigma
enigma started at Tue May 18 14:57:15 CEST 2021
enigma stopped at Tue May 18 15:01:06 CEST 2021
enigma stopped at Tue May 18 15:03:05 CEST 2021
enigma started at Tue May 18 15:03:06 CEST 2021
enigma stopped at Tue May 18 15:07:40 CEST 2021
enigma stopped at Tue May 18 15:09:42 CEST 2021
enigma started at Tue May 18 15:09:43 CEST 2021
enigma stopped at Wed May 19 09:54:28 CEST 2021 -before reboot (stopped via "K" symlink as expected)
enigma stopped at Wed May 19 09:56:36 CEST 2021 -after reboot (why is it stopped after reboot?)
enigma started at Wed May 19 09:56:38 CEST 2021 -after reboot (started after firstly being stopped)
#
Why is it firstly stopped after reboot and not only started?
Is this expected (by design) behavior on AIX?
If I delete the K30enigma symbolic link from /etc/rc.d/rc2.d directory, then the application only gets started after the reboot, not firstly stopped then started.
The problem with this is that it does not get stopped before reboot.
Regards,
Romeo
------------------------------
Romeo Mikulic
------------------------------