Enabling automatic MSSQL restart every hour

Source: Internet
Author: User

A good friend who worked as a personal website a few days ago asked me if I could make a small tool. Instead of Manually restarting ms SQL and Apache2 services once. I spent an hour at the company secretly giving the first answer. the main idea is to use Timer on the console to execute Net Stop and Net Start once every hour. my friend said that it would be enough for an hour and no configuration is required. Therefore, the process of using the configuration file is saved. here is all the code:

Code

Using System;
Using System. Collections. Generic;
Using System. Text;
Using System. Diagnostics;

Run namespace directly on the console
{
Class Program
{
Private static int iii;
Private static int ispan;

Static Program ()
{
Iii = 0;
Ispan = 1000*60*60;
}

Static void Main (string [] args)
{
Console. WriteLine ("every six hours, refresh the output information! Click any button to exit! ");
Try
{
Panda_Restart ();

System. Timers. Timer t = new System. Timers. Timer (ispan );
T. Elapsed + = new System. Timers. ElapsedEventHandler (t_Elapsed );
T. AutoReset = true;
T. Enabled = true;

Console. Read ();
}
Catch (Exception ex)
{
LogToSys ("an exception occurred when the program is automatically restarted:" + ex. Message, EventLogEntryType. Error );
}
}

Static void t_Elapsed (object sender, System. Timers. ElapsedEventArgs e)
{
// Hello ();
Panda_Restart ();
ClearMoniter ();
}

Private static void Hello ()
{
Console. WriteLine ("Hello! ");
&

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.