Re: How to create a "delay" service?
- From: "Hank Arnold" <rasilon@xxxxxxx>
- Date: Wed, 15 Jun 2005 04:33:43 -0400
I needed to stop a service and then restart it. If I ran both commands in a
batch file, the NET START command failed. I created a batch file that
"sleeps" for the specified number of seconds (I got it off the internet).
then created a batch file that stops the service, sleeps for xx seconds and
then starts the service. Hope this helps....
SLEEP.CMD
=========
@ECHO OFF
:: Use local environment
SETLOCAL
:: Check if a timeout period is specified
IF [%1]==[] GOTO Syntax
:: Filter out slashes, they make the IF command crash
ECHO.%1 | FIND "/" >NUL
IF NOT ERRORLEVEL 1 GOTO Syntax
:: Check if specified timeout period is within limits
IF %1 LSS 1 GOTO Syntax
IF %1 GTR 3600 GOTO Syntax
:: Check for a non-existent IP address
:: Note: this causes a small extra delay!
IF NOT DEFINED NonExist SET NonExist=10.255.255.254
PING %NonExist% -n 1 -w 100 | FIND "TTL=" >NUL
IF NOT ERRORLEVEL 1 (
SET NonExist=1.1.1.1
PING %NonExist% -n 1 -w 100 | FIND "TTL=" >NUL
IF NOT ERRORLEVEL 1 GOTO NoNonExist
)
:: Use PING time-outs to create the delay
PING %NonExist% -n 1 -w %1000 >NUL
:: Show online help on errors
IF ERRORLEVEL 1 GOTO Syntax
:: Done
GOTO End
:NoNonExist
ResartMisys.CMD
=============
Echo off
net stop mhc_server
call "c:\Batch Files\go2sleep.cmd" 30
net start mhc_server
exit
--
Regards,
Hank Arnold
"John Doe" <JohnDoe@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4952784A-FAEA-4FA3-8882-4A42DE3D71A0@xxxxxxxxxxxxxxxx
>I want to delay a service starting by creating a service that pauses for a
> few seconds and making the other dependent on it. Anyone know how?
>
> For those who need more info ...
>
> Obviously when thinking about this people will point me are various
> articles
> like:
>
> "How to delay loading of specific services"
> http://support.microsoft.com/kb/q193888/
>
> which talks about making services dependent on other services. However
> this
> doesn't work in my environment.
>
> Specifically I have Exchange Server 2003 running on a server connected to
> a
> SAN via iSCSI. The Server service is dependent on the iSCSI service,
> however
> that dependency doesn't quite work. As soon as the iSCSI service "starts"
> the
> next service gets the signal to start. Not good enough, as the iSCSI
> drives
> haven't come up yet.
>
> This can be shown with an example by creating services like the following:
>
> service "Begin" - write a file with the time
> service "Delay" - a "sleep 10" command
> service "End" - write a file with the time
>
> By making each of the created services dependent on the next one you would
> expect that a file is written with a start and end time at least 10
> seconds
> apart. What happens is that there is little to no delay between the
> writes.
> It would seem that the "Delay" service starts a command then signals to
> the
> next service it can start. This makes sense as the service could be doing
> anything, in this case it is just running SLEEP. As far as service control
> is
> concerned the service is started, move on the next one.
>
> This is similar to what happens with our iSCSI startup. The iSCSI service
> is
> started by the drives haven't initiated. So when the Server service starts
> the drives are not assigned admin shares (meaning Veritas restores don't
> work!), and later when the Exch IS service starts Exchange databases don't
> mount.
>
> Any ideas on how to create a real delay service? The fundamental issue is
> pausing long enough after the iSCSI service is started to allow the drives
> to
> initiate before starting the next service.
>
> Thanks heaps.
.
- Follow-Ups:
- Re: How to create a "delay" service?
- From: John Doe
- Re: How to create a "delay" service?
- References:
- How to create a "delay" service?
- From: John Doe
- How to create a "delay" service?
- Prev by Date: Re: DC Rebuild
- Next by Date: .NET Framework 1.1
- Previous by thread: Re: How to create a "delay" service?
- Next by thread: Re: How to create a "delay" service?
- Index(es):
Relevant Pages
|