Implement timed restart of Apache and MySQL

Source: Internet
Author: User
Tags mssqlserver

Use the AT command to add a scheduled task. For the syntax, Run "cmd"-"execute the command" at/"in" window-"start"-"to display the AT command syntax. The following describes how to enable the server to regularly start Apache and MYSQL:

1. Create an autostartserver. BAT file in the C: root directory, right-click it, set the file content to the following, and save it:CopyCodeThe Code is as follows: @ echo off
Net stop apache2
Net start apache2
Net stop MySQL
Net start MySQL

Note: The above apache2 and MySQL are service names.

2. "Start"-"run" cmd "-" run the command "at c: \ autostartserver. Bat"
In this way, the system automatically restarts Apache and MySQL at every morning.
Note: 04: 00 indicates the restart time, and c: \ autostartserver. Bat indicates the BAT file address in step 1.

Sometimes there is a certain interval in the middle, which can be implemented through the following code. Copy codeThe Code is as follows: net stop SQLServerAgent
Net stop MSSQLServer
Echo. wscript. Sleep (50000)> S. vbs
Cscript // nologo S. vbs
Del S. vbs
Net start MSSQLServer
Net start SQLServerAgent

Related Article

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.