Become super-efficient at starting & stopping services via scripting

1

Which would you rather do? Click stop (or start) over and over, while waiting in between the services to make sure everything is up and running ... OR ... click one button and go have lunch?

Service Window vs Batch Script

Honestly I prefer the lunch option. (And for administrators, the quickest option is always the best if you are dealing with restarting services outside of a maintenance period.)

Using some of the information I posted previously on SASCommunity.org I developed the following scripts to either start or stop the services. This works pretty darn well on my Windows7 machine.

To get these scripts working in your windows environment, modify the "Service Name" to exactly what your service is called. (I always open the service from the Service Manager, then copy the name from the properties.) If you are still on 9.2, just remove the SAS Framework Data Server line. Also, I would recommend tweaking the timeout amounts (which creates a specified delay in seconds) to fit your system. My guess is that your server is much faster than my laptop.

Note that for you UNIX/etc users out there, a sh script is the ticket.

Start Script for 9.3

sc start "SAS [EBIServer93-Lev1] SASMeta - Metadata Server"
timeout 10
sc start "SAS [EBIServer93-Lev1] Object Spawner"
timeout 5
sc start "SAS [EBIServer93-Lev1] FrameworkServer - SAS Framework Data Server"
timeout 5
sc start "SAS [EBIServer93-Lev1] Remote Services"
timeout 15
sc start "JBoss - SASServer1"

Stop Script for 9.3

sc stop "JBoss - SASServer1"
timeout 400
sc stop "SAS [EBIServer93-Lev1] Remote Services"
timeout 30
sc stop "SAS [EBIServer93-Lev1] FrameworkServer - SAS Framework Data Server"
sc stop "SAS [EBIServer93-Lev1] Object Spawner"
timeout 10
sc stop "SAS [EBIServer93-Lev1] SASMeta - Metadata Server"

Share

About Author

Angela Hall

Senior Technical Architect

Angela offers tips on using the SAS Business Intelligence solutions. She manages a team of SAS Fraud Framework implementers within the SAS Solutions On-Demand organization. Angela also has co-written two books, 'Building BI using SAS, Content Development Examples' & 'The 50 Keys to Learning SAS Stored Processes'.

Related Posts

1 Comment

  1. Hi Angela,

    Great post! This scripting technique you describe for service start/stops can be especially handy when you have multiple SAS services spread over multiple machines. A nice thing about SC is that it can also be used to start/stop services on a different machine such as:

    sc start \mysascomputeserver "SAS [EBIServer93-Lev1] Object Spawner"

    As an alternative to tuning sleep times, SC can also be used to iteratively poll the service state. I found out about this when I stumbled on some scripts that a nice fellow posted in answer to someone's stackoverflow question:

    http://stackoverflow.com/questions/1405372/stopping-starting-a-remote-windows-service-and-waiting-for-it-to-open-close

    Cheers
    Paul

Back to Top