Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Monitoring multiple process scripts in tomcat

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

The script given by Mr. Ye.

During the trial operation of an application system, the web end often exits. In order to ensure the emergency response of the system, the WEB end is deployed into 5 nodes, which are called zjgpwebnode1~5, and the monitoring process is executed:

1. Create a monitoring execution script file / home/monitor.sh, which contains the following contents:

SHELL=/bin/bash

LANG=zh_CN.GB18030

SUPPORTED=zh_CN.GB18030:zh_CN:zh_CN.UTF-8:zh:en_US.UTF-8:en_US:en

LD_LIBRARY_PATH=/lib:/usr/lib:/lib64:/usr/lib64

Export LANG

Export SUPPORTED

Export LD_LIBRARY_PATH

Su-root > > / home/resetlog.log

LANG=zh_CN.GB18030

SUPPORTED=zh_CN.GB18030:zh_CN:zh_CN.UTF-8:zh:en_US.UTF-8:en_US:en

LD_LIBRARY_PATH=/lib:/usr/lib:/lib64:/usr/lib64

Export LANG

Export SUPPORTED

Export LD_LIBRARY_PATH

WEBLOGIC1= `ps-ef | grep-c Dweblogic.Name= zjgpwebnode1`

WEBLOGIC2= `ps-ef | grep-c Dweblogic.Name= zjgpwebnode2`

WEBLOGIC3= `ps-ef | grep-c Dweblogic.Name= zjgpwebnode3`

WEBLOGIC4= `ps-ef | grep-c Dweblogic.Name= zjgpwebnode4`

WEBLOGIC5= `ps-ef | grep-c Dweblogic.Name= zjgpwebnode5`

WEBLOGIC6= `ps-ef | grep-c Dweblogic.Name= myserver`

If [$WEBLOGIC1! = "2"]; then

Date > > / home/resetlog.log

Echo "Now Node1 is down!" > > / home/resetlog.log

Locale > > / home/resetlog.log

Set > > / home/resetlog.log

Echo "Restart Node1 start" > > / home/resetlog.log

Cd / home/weblogic/bea/user_projects/domains/webcluster/

Nohup. / startManagedWebLogic.sh zjgpwebnode1 > 1.out &

Echo "Restart Node1 end" > > / home/resetlog.log

Else

Date > > / home/resetlog.log

Echo "Node1 is OK!" > > / home/resetlog.log

Fi

If [$WEBLOGIC2! = "2"]; then

Date > > / home/resetlog.log

Echo "Now Node2 is down!" > > / home/resetlog.log

Locale > > / home/resetlog.log

Set > > / home/resetlog.log

Echo "Restart Node2 start" > > / home/resetlog.log

Cd / home/weblogic/bea/user_projects/domains/webcluster/

Nohup. / startManagedWebLogic.sh zjgpwebnode2 > 2.out &

Echo "Restart Node2 end" > > / home/resetlog.log

Else

Date > > / home/resetlog.log

Echo "Node2 is OK!" > > / home/resetlog.log

Fi

If [$WEBLOGIC3! = "2"]; then

Date > > / home/resetlog.log

Echo "Now Node3 is down!" > > / home/resetlog.log

Locale > > / home/resetlog.log

Set > > / home/resetlog.log

Echo "Restart Node3 start" > > / home/resetlog.log

Cd / home/weblogic/bea/user_projects/domains/webcluster/

Nohup. / startManagedWebLogic.sh zjgpwebnode3 > 3.out &

Echo "Restart Node3 end" > > / home/resetlog.log

Else

Date > > / home/resetlog.log

Echo "Node3 is OK!" > > / home/resetlog.log

Fi

If [$WEBLOGIC4! = "2"]; then

Date > > / home/resetlog.log

Echo "Now Node4 is down!" > > / home/resetlog.log

Locale > > / home/resetlog.log

Set > > / home/resetlog.log

Echo "Restart Node4 start" > > / home/resetlog.log

Cd / home/weblogic/bea/user_projects/domains/webcluster/

Nohup. / startManagedWebLogic.sh zjgpwebnode4 > 4.out &

Echo "Restart Node4 end" > > / home/resetlog.log

Else

Date > > / home/resetlog.log

Echo "Node4 is OK!" > > / home/resetlog.log

Fi

If [$WEBLOGIC5! = "2"]; then

Date > > / home/resetlog.log

Echo "Now Node5 is down!" > > / home/resetlog.log

Locale > > / home/resetlog.log

Echo "Restart Node5 start" > > / home/resetlog.log

Cd / home/weblogic/bea/user_projects/domains/webcluster/

Nohup. / startManagedWebLogic.sh zjgpwebnode5 > 5.out &

Echo "Restart Node5 end" > > / home/resetlog.log

Else

Date > > / home/resetlog.log

Echo "Node5 is OK!" > > / home/resetlog.log

Fi

If [$WEBLOGIC6! = "2"]; then

Date > > / home/resetlog.log

Echo "Now TimerNode is down!" > > / home/resetlog.log

Echo "Restart Timer Node start" > > / home/resetlog.log

Cd / home/weblogic/bea/user_projects/domains/zjgpwebtimer

Nohup. / startWebLogic.sh > > / home/logs/timer-web.log &

Echo "Restart Timer Node end" > > / home/resetlog.log

Else

Date > > / home/resetlog.log

Echo "Timer Node is OK!" > > / home/resetlog.log

Fi

Exit

Please note that the file must be edited in UltraEdit, and must be saved in unix format, mainly because of the enter newline character, otherwise the "syntax error: unexpected end of file" error is reported.

In the actual execution, it is found that when the crond system is used to plan the task, the environment variables are not consistent with the original root user login, resulting in garbled code in the system, so the environment variables needed for the operation of the business system are added to the script.

2. After creating the monitor.sh file, you must add the execution task to the scheduled task:

Execute: crontab-e, add

* / 20 * / home/monitor.sh

Note: it means to execute the monitoring program monitor.sh every 20 minutes.

3. Restart the scheduled task program after adding to make the scheduled task effective:

/ sbin/service crond restart

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report