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.

0

2 Answers 2

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

1
  • 2
    The native utility is timeout.
    – jscott
    Jun 2, 2012 at 20:56
1

In Powershell one can use this to sleep 10 seconds:

Start-Sleep -s 10

1
  • 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. Jun 2, 2012 at 21:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .