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! ");
&