Win Server 2008: Task Scheduler runs programs twice or late

Posted by SomeName on Server Fault See other posts from Server Fault or by SomeName
Published on 2010-05-05T13:06:58Z Indexed on 2010/05/05 13:18 UTC
Read the original article Hit count: 255

Hi,

I need to restart a service every day. I have logon hours restricted at 3:00 am, and the server will logout existing TS connections.

I have two tasks scheduled:

  1. "Daily At 3:20 am every day" "start a program" "c:\windows\system32\sc.exe stop myservice"
  2. "Daily At 3:22 am every day" "start a program" "c:\windows\system32\sc.exe start myservice"

I came in today to notice that the service wasn't running. I've been digging in logs, and found these entries:

  1. For stop task, history:

    a) 3:29:35 am: Action Completed (sc result code 0)

    b) 3:20:00 am: Action Completed (sc result code 0)

  2. For start task, history:

    a) 3:29:35 am: Action Completed (sc result code ERROR_SERVICE_ALREADY_RUNNING 1056 (0x420))

    b) 3:22:01 am: Action Completed (sc result code 0)

Checking event logs shows me:

a) 3:29:35 am, Application log, Source myservice, "The service was stopped"

b) 3:29:25 am, System log, Source Service Control Manager, "The myservice service entered the stopped state"

So,

  1. What would have caused both tasks to run at 3:29 am?
  2. Why don't I see a message from the SCM saying that the service entered the running state?
  3. Is this the preferred way to do this?

Thanks!

© Server Fault or respective owner

Related posts about task-scheduler

Related posts about windows-server-2008