Solved

Need help regarding the scheduled stop/start of Windows services

Posted on 2004-09-01
10
573 Views
Last Modified: 2010-08-05
Thanks in advance for any assistance.

I need to create a job that will stop and restart a set (3) of Windows services.  Situation:  Running a BI Tool (BusObj) in production environment.  The software polls a database repository every couple of minutes in order to create trace logs.  Our DBA Group stops the database at night in order to create backups.  When this happens, my software breaks because of the connectivity problem.  So, after the nightly backup of the db, I need to stop and restart my software.  I hope that's clear.  The server is running Win 2k Server.  There are 3 services that need to be stopped/restarted.  Two problems:

I don't know how to write this cron job (I think that's what i need).
The glitch:  After stopping the services, I need to wait until they are completely stopped (about 1.5 minutes) before starting them again.

Any assistance is greatly appreciated.  I'm coming into a server down situation every morning.
0
Comment
Question by:jdharris5954
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 20

Accepted Solution

by:
Debsyl99 earned 500 total points
ID: 11953974
Hi

Could you not use task scheduler to schedule two batch files to run - say three minutes apart? The first one would stop the services at a suitable time after the backup had finished

ie net stop sevice1
net stop service2 etc

Then the next batch file would start the services again ie

net start service1
net start service2

Deb :))

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 11954025
1) Start->Run->Regedit
2) Navigate to HKey_Local_Machine\SYSTEM\CurrentControlSet\Services
3) Find the service identifiers listed there (ImagePath should give you the name, or you can enclose the display name in quotes)
4) Create a recycle.bat file:

::----begin code--------
@echo off
net stop "My first service"
net stop "My second service"
net stop mythirdsvc
::90 second delay
ping 127.0.0.1 -n 90
net start "My first service"
net start "My second service"
net start mythirdsvc
::-----end code-----
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 11954032
Oops - a little bit of overlap there... apols Debsyl99
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 3

Expert Comment

by:ynaught
ID: 11954034
Hi jdharris5954,
    This is an untested idea, it may not be the right one... but it is one.

    Create a two Batch files
    one to stop the services
ie.
    net stop service name1
    net stop service name2
    net stop service name3

the other to start the services
    net start service name1
    net start service name2
    net start service name3

now you can use the windows schedule service to run these run the start one a few minutes after the stop one...

Let me know
   
Regards,
0
 
LVL 3

Expert Comment

by:ynaught
ID: 11954070
sorry as well... a little slow at typing here...
0
 
LVL 5

Expert Comment

by:tebacher
ID: 11954103
Would you be able to write a simple bat file to stop and start the services, then have it run as a scheduled task?

If so, here's the commands to do so:

NET STOP "NAME OF SERVICE"
NET START "NAME OF SERVICE"

******(note: you DO want the quotes around the service name!)********

I have a program called "sleep.exe" that will allow you to force the script to wait a certain number of seconds before going on.  If you need this (I don't think you will, dos shows when the service is stopped before providing the prompt agian) I can get it to you.

So, experiment with the net stop and net start commands to see what they do, let me know if they will work.

I can write a very simple script that will stop and start the services if you don't know how, but it will be VERY simple.  I don't have the experience with more complicated things.

Let me know if you have any questions
0
 
LVL 5

Expert Comment

by:tebacher
ID: 11954131
Yep, me too.  When I started typing there were NO posts!  I guess I'm just too slow!  Sorry for the exact same advise that everyone else gave!
0
 
LVL 20

Expert Comment

by:Debsyl99
ID: 11954145
No apols necessary SirB ;-) - Looks like we all agree on the sceduled task batch file idea though ;))
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 11954150
Hey - great minds think alike, eh?  LOL
0
 

Author Comment

by:jdharris5954
ID: 11954213
Thanks everyone for your help.  Please excuse my lack of experience here, I've not worked much with"net".  I've avoided these kinds of things as long as I could, time to learn something new :=).

I really appreciate the fast responses.

-John
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
auto copy 8 616
Mystery using IF with Concatenate using MS Excel 10 674
Can you expand C: in Windows 2000? 5 134
Can’t delete a file 14 163
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Each year, investment in cloud platforms grows more than 20% (https://www.immun.io/hubfs/Immunio_2016/Content/Marketing/Cloud-Security-Report-2016.pdf?submissionGuid=a8d80a00-6fee-4b85-81db-a4e28f681762) as an increasing number of companies begin to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question