Business background:Often there is a business in the web that needs to be timed out, but in a clustered environment, if timed tasks are turned on in multiple servers at the same time, the database hangs up, and only one scheduled task should actually access the database. How to solve this problem: 1, multi-server cluster, directory mount. Only one server holds a scheduled task, and when mounted, excludes the profile of the scheduled task, allowing only one server to start the scheduled task. 2, the deployment of a single server, used to run the scheduled Task 3, the use of Linux scripts, access to the Cluster Server page or action, there must be a server received the request, and then perform the timing. Here is the 3rd way, the disadvantage is: the server is accessed by the page or action need to do security restrictions.
First, configure the Linux timer task: Vi/etc/crondtab
0 1 * * *Root/dbdata/Backup/CMS/Async.SH
Then, in async.sh, send an email alert if the request goes wrong:
#!/bin/bash
Dir="/home/webtrn/CrontabDir"
echo `date +"%Y-%m-%d-%H-%M"` >> $Dir/checklearntime.log
wget-T1 http://www.baidu.com /Checkserver/XXX.JSP-o $Dir/Wgetchecklearntime.Log
grep-Q"404"$Dir/Wgetchecklearntime.Log||grep-Q"302"$Dir/Wgetchecklearntime.Log
if [ $ != 0 Span class= "PLN" style= "Color:rgb (72,72,76)" " "; then
echo "checklearntime have done" >> $Dir/checklearntime.log
else
echo " Checklearntime is err or " >>, $Dir / checklearntime log
echo " Checklearntime is err or " | Mail - s "WEBTRN" [email protected] com
echo "checklearntime is error" | mail -s "webtrn" [email protected].com
fi
rm -f XXX.jsp
rm -f $Dir/wgetchecklearntime.log
Linux timed Task access page instead of quartz cluster