You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Here two jobs are used to restart the MySQL Windows Service at a particular time.
The first job service_stop stops the service and the second job service_start starts it.
Both jobs use the Windows net.exe application.
This program can be found in the Windows system32 subdirectory.
To specify the program path you can use the %windir% environment variable.

Note that as presented here the jobs will work on Windows systems up to and including XP.
On Vista and Windows 7/8 an additional job will be required to ensure that the user JobScheduler is using (usually, "scheduler") has the necessary permissions to start and stop programs.

The simplest solution is to set ....

Paste this sample into a file ./config/live/service_stop.job.xml:

 {{<?xml version="1.0" encoding="iso-8859-1"?>
 <job>
   <script language="shell"><![CDATA[ 
     %windir%\system32\net.exe stop MySQL
   ]]></script>
   <run_time>
     <period single_start = "03:00"/>
   </run_time>
 </job>	}}

Paste this sample into a file ./config/live/service_start.job.xml:

 {{<?xml version="1.0" encoding="iso-8859-1"?>
 <job>
   <script language="shell"><![CDATA[ 
     %windir%\system32\net.exe start MySQL
   ]]></script>
   <run_time>
     <period single_start = "03:02"/>
   </run_time>
 </job> }}

Instead of using a delay of several minutes in the hope that the first job has been completed before the second starts, we recommend that a third script is used to start
the second job after the first job, should the first one complete successfully.
You could configure the second job as a successor to the first job.

Paste this sample into a file ./config/live/service_restart.job.xml:

 {{<?xml version="1.0" encoding="iso-8859-1"?>
 <job>
   <script language="shell"><![CDATA[ 
     %windir%\system32\net.exe stop MySQL
   ]]></script>
   <run_time>
     <period single_start = "03:00"/>
   </run_time>
   <commands on_exit_code="success">
     <start_job job="service_start"/>
   </commands>
 </job> }}
  • No labels