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.

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

| improve this answer | |
  • 2
    The native utility is timeout. – jscott Jun 2 '12 at 20:56
1

In Powershell one can use this to sleep 10 seconds:

Start-Sleep -s 10

| improve this answer | |
  • 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 2 '12 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.