Prioritizing scripts under /etc/init.d/

Hello Team,

I work on IBM TWS ( Tivoli Workload Scheduler ) administration. I have placed TWS service stop and start script under directory /etc/init.d/ in my Linux server and coded email alert when the script has been executed with stop or start parameter .

I am receiving email notification only when start parameter has been passed to script after server reboot.

But I also expect email notification when server gets shutdown. Meaning when stop parameter passed to the script I am not receiving the email.

After analyzing the situation I found sendmail service is getting stopped before TWS service stop script executed.

Is there any way I could prioritize the execution of TWS service stop script before send mail function killed/stopped during the server shutdown.

And start the sendmail before start parameter passed to the TWS service script.

Kindly assist.

Regards,
Madhusudan

Service start/stop is OS-specific. What OS do you have?

uname -sr
1 Like

Thanks for looking at my query..

I am running RHEL Server release 5.11

Regards,
Madhu

---------- Post updated at 05:02 PM ---------- Previous update was at 04:59 PM ----------

uname -sr

Linux 2.6.18-402.el5

Regards,
Madhu

Do you have /etc/init.d/sendmail? (Alternatives to sendmail are postfix, qmail, exim, ...)
/etc/init.d/sendmail does not have an LSB header that describes services and dependency.
Then try to manually change the kill script order.
Say your service script is /etc/init.d/tws then list the kill order with

echo /etc/rc.d/rc?.d/K*sendmail /etc/rc.d/rc?.d/K*tws

And rename the Ktws to a number that is little lower than the Ksendmail number!
For example there is /etc/rc.d/rc0.d/K30sendmail and /etc/rc.d/rc0.d/K40tws:

mv /etc/rc.d/rc0.d/K40tws /etc/rc.d/rc0.d/K29tws

Do this also for the other run levels rc1.d, rc2.d, ...
Attention: there can be other dependencies with other services, so this needs to be tested!
Last but not least, even if the kill order is correct it could be that sendmail is killed before it can deliver the E-mail.
E.g. it has queued the mail but then it is killed. Then it will deliver the mail when it is started again (e.g. when the system boots up).