Using Scheduled Tasks in Linux +php Web programs (GO)

Source: Internet
Author: User

Use Scheduled tasks in Linux +php Web-based programs to monitor Web server health "every 5 minutes and email alerts"
One, my monitoring server environment:
Rhel5.5+apache2.2+php5
Second, function Description:
Write a PHP page that implements the following functions:
Request the content of one page of the Web server to be monitored, if the data is not returned, or the data returned does not contain the code I expected "for the custom error page", then I think the Web service has a problem "outage or content overwrite attack", then send a message, This mail can be tied to the phone "139 mailbox can Do"
And what am I going to do when I'm planning a mission? Every 5 minutes, ask me for this monitoring page.
Finally, I realized the purpose of checking the health of the server every 5 minutes. Third, the description
Here the code to send the message, but also refer to the contributions of netizens, non-original.
Send Mail has two functions, one is used under the Wndows server, one is used under the Linux server, if you are lnux, please use the function with _unix suffix.
Iv. How to achieve this task?
Edit/etc/crontab, add the following line:

*/5 * * * * Root/usr/bin/curl http://localhost/monitor.php

"Explanation, the first field, which represents the execution of every 5 minutes"
Restart the Crond service using the service crond restart command after saving
Five, PHP code:
Paste the source code:
monitor.php:

Using Scheduled Tasks in Linux +php Web programs (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.