Re: How to create a "delay" service?



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.


.



Relevant Pages

  • Re: How to create a "delay" service?
    ... > "How to delay loading of specific services" ... > which talks about making services dependent on other services. ... The Server service is dependent on the iSCSI service, ... This batch file might look like this: ...
    (microsoft.public.windows.server.general)
  • Re: Pausing/Waiting in C
    ... of "events" to be popped off, separated by a command to pause reading off ... only clock() is part of the ANSI Standard. ... If you're trying to implement a delay and all you have available ...
    (comp.lang.c)
  • Re: ide-cd problem
    ... > getting the exact same symptoms I got with 2.6.9 before upping the delay to ... the command before seems to have an expectation of a 2048 ... and once the transfer has taken place with DRQ not asserted and rq len having ... any really definitive statement on DRQ assertion in this case. ...
    (Linux-Kernel)
  • How to create a "delay" service?
    ... "How to delay loading of specific services" ... which talks about making services dependent on other services. ... The Server service is dependent on the iSCSI service, ... started by the drives haven't initiated. ...
    (microsoft.public.windows.server.general)
  • How to create a "delay" service?
    ... "How to delay loading of specific services" ... which talks about making services dependent on other services. ... The Server service is dependent on the iSCSI service, ... started by the drives haven't initiated. ...
    (microsoft.public.windows.server.setup)