Implement timed restart Apache and MySQL method under Windows

Source: Internet
Author: User
Tags mssqlserver

Sometimes for servers with better efficiency, you can restart Apache services on a timed basis. Make the site run faster.

Add a scheduled task with the AT command. For the use of syntax can go to window-"Start"-"Run" cmd "-" execute Command "at/", so that the interface will display the syntax of the AT command. Below we explain how to get the server to start Apache and MySQL on time:

1, in the C: Packing directory to create a new Autostartserver.bat file, and then right-click Edit, the file content is set as follows to save:

Copy CodeThe code is as follows:
@ECHO OFF
net stop Apache2
net start apache2
net stop MySQL
net start MySQL
Description: The above apache2 with MySQL for the service name.

2, "Start"-"Run" cmd "-" Execute Command "at 04:00 C:\autostartserver.bat"
This way, the system automatically restarts Apache and MySQL every 4 o'clock in the morning.
Description: 04:00 Restart time, C:\autostartserver.bat is the first step of the bat file address

Sometimes the middle requires a certain interval, can be implemented by 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

The SQL Server service starts at a interval of 50 seconds (50000 milliseconds), because SQL Server shuts down and starts at a certain time, and MySQL does not require a time interval.

Implement timed restart Apache and MySQL method under Windows

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.