Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Conversion corrections

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px

Restarting a Windows Service at a particular time is demonstrated in this FAQ with two jobs that respectively stop and start the Windows Update Service.
The Windows Update Service is used in this example as it is neither system-critical (in the short term) and can be stopped and started by a single command without further input.
It is assumed that JobScheduler running these jobs is configured to run as a service.

...

Paste the following code into a file ./config/live/service_stop.job.xml:

Code Block

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

Paste the following code into a file ./config/live/service_start.job.xml:

Code Block

 {{&lt;<?xml version="1.0" encoding="iso-8859-1"?&gt;>
 &lt;job&gt;<job>
   &lt;script<script language="shell"&gt;&lt;><![CDATA[ 
     %windir%\system32\net.exe start wuauserv
   ]]&gt;&lt;/script&gt;></script>
   &lt;run_time&gt;<run_time>
     &lt;period<period single_start = "03:02"/&gt;>
   &lt;</run_time&gt;time>
 &lt;/job&gt; }}</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 the following code into a file ./config/live/service_restart.job.xml:

Code Block

 {{&lt;<?xml version="1.0" encoding="iso-8859-1"?&gt;>
 &lt;job&gt;<job>
   &lt;script<script language="shell"&gt;&lt;><![CDATA[ 
     %windir%\system32\net.exe stop wuauserv
   ]]&gt;&lt;/script&gt;></script>
   &lt;run_time&gt;<run_time>
     &lt;period<period single_start = "03:00"/&gt;>
   &lt;</run_time&gt;time>
   &lt;commands<commands on_exit_code="success"&gt;>
     &lt;start<start_job job="service_start"/&gt;>
   &lt;/commands&gt;
 &lt;/job&gt; }}</commands>
 </job>