4

How to schedule a task X minutes after Windows Server 2003 starts?

In "Scheduled Tasks" one can specify "When my computer starts" but I see no way to specify delay.

What I am trying to achieve: there is a service (JIRA) that even though dependent on SQL Server service still doesn't wait long enough for SQL Server to become fully operational. So JIRA service fails to connect to the database and needs to be restarted manually after each server reboot. My plan is to add "SC stop" and "SC start" commands for JIRA service 3 minutes after server starts.

Joe Schmoe
  • 315
  • 7
  • 15

2 Answers2

3

In your batch file with the sc.exe command just wait for x minutes before running sc.exe.

I don't remember if 2003 has something native for this, but there is always 'sleep.exe' in the Windows Server 2003 Resource Kit:

sleep.exe 180
sc.exe start...

waits for 3 minutes

Peter Hahndorf
  • 14,058
  • 3
  • 41
  • 58
  • 2
    The native utility is [`timeout`](http://technet.microsoft.com/en-us/library/cc754891(v=ws.10).aspx). – jscott Jun 02 '12 at 20:56
1

In Powershell one can use this to sleep 10 seconds:

Start-Sleep -s 10

Joe Schmoe
  • 315
  • 7
  • 15
  • 2
    I would not use Powershell in this case, it loads the dot.Net runtime which is a lot of overhead just for waiting a little bit. – Peter Hahndorf Jun 02 '12 at 21:04