Scheduling the Start, Stop, Restart or Publishing of ArcGIS Server Services


There may be situations where you need to automate the Start/ Stop/ Restart/ Publishing of all or some of your ArcGIS Server Services. This may be for maintenance reasons (where you want to do a restart at a time when no users are logged on) or to account for updates to data (e.g. where a restart is required after adding new data for a time aware map service).

This can be achieved through the combined use of a handy little utility called AGSSOMBatch File and Task Scheduler in Windows.

1) So let’s take a look at the first component: AGSSOM. This was developed by ESRI Boston and is available via a free download from: http://resources.arcgis.com/gallery/file/net-web-adf/details?entryID=16BABD9A-1422-2418-8828-AC5EE09678BA

To use it, download the zip and extract its contents to your server. Note there are two versions to download; one for ArcGIS Server 9.3.1 and one version 10 (select the appropriate one).

The AGSSOM.exe is found in either of the following paths: \\AGSSOMv9.3.1\AGSSOMv9.3.1\bin\x86\Release\ or \\AGSSOMv10.0.2\AGSSOMv10.0.2\bin\x86\Release\

2) Next you need to get you head around the scripting side of things. AGSSOM.exe is capable of performing the following operations:

s (START); x (STOP); r (RESTART); p (Pause);  LIST; LISTTYPES; DESCRIBE; PUBLISH; STATS

You will need to specify which operation will be applied to which service(s). ESRI Boston have compiled the text below to illustrate the format you must use:

AGSSOM [server] {-s | -start} {[servicename [servicetype]] | *all*}

AGSSOM [server] {-x | -stop} {[servicename [servicetype]] | *all*}

AGSSOM [server] {-r | -restart} {[servicename [servicetype]] | *all*}

AGSSOM [server] {-p | -pause} {[servicename [servicetype]] | *all*}

AGSSOM [server] -delete servicename servicetype [N]

AGSSOM [server] -list [likename] [servicetype]

AGSSOM [server] -listtypes

AGSSOM [server] -describe [likename] [servicetype]

AGSSOM [server] -publish MXDpath [servicetype] [servicename]

AGSSOM [server] -stats [[[likename] [servicetype]] | *all*] [starttime]

 If omitted the {server} argument will default to localhost.

To put the above into action you will need to open up a blank textfile (.txt) and write in your desired command. Here are a few examples I put together in order to help you (note that I have copied my AGSSOM.exe to ‘C:\Client’ to shorten the string):

Restart all map services on Localhost:

C:\Client\AGSSOM.exe localhost -r *all* mapserver

Stop Map service named ‘BackgroundNoAA’ on server named ‘lap-303649:

C:\Client\AGSSOM.exe lap-303649 -x BackgroundNoAA mapserver

Restart map service called water (in folder called Dekho) on Localhost:

C:\Client\AGSSOM.exe localhost -r Dekho/water mapserver

Publish an mxd called ‘untitled’ and name the new map service ‘OutPutName:

C:\Client\AGSSOM.exe localhost -publish “C:\untitled.mxd” MAPSERVER “OutPutName”

Note that for services other than map services, the ‘mapserver’ component of the string will have to be updated and that the ‘publish’ command requires the use of double quotations  (““). Once written, save the text file and manually change its extension from .txt to .bas. The file will now act as batch file. Double clicking it will run the .exe using the parameters you provided.  It is now worth doing some testing to make sure your map services are being started/stopped/etc successfully.

3) When you are happy that your batch file is working as expected, it is time to schedule its execution using Scheduled Task Wizard in Windows. The Scheduled Task Wizard in Windows walks you through the process of setting up the task. It is straight forward, but I have included the required steps below (in Windows 7):

– Open the wizard by clicking Start > All Programs > Accessories > System Tools > Scheduled Tasks > Task Scheduler.

– Once open, click ‘Create Basic Task’

– Enter a name and description for the task and click next

– Specify how often the task should occur and click next

– Specify when the task should occur and click next

– Click the ‘Start a Program’ option and click next

– Navigate to your batch file and click next

– Click Finish

Finally, you should check that windows can successfully execute your batch file:

– Find the newly created task in the ‘Active Tasks’ window and double-click on it

– Click ‘Run’ to test it works (the batch script should fire up successfully).

Done, your services should now restart when you are tucked up in bed.

On a related thread, I have found the following instructions on updating your ArcGIS Sever configuration files:

http://gistom.blogspot.com/2011/10/update-all-arcgis-server-service.html

John H

5 thoughts on “Scheduling the Start, Stop, Restart or Publishing of ArcGIS Server Services

  1. MLF

    Where can I find documentation describing exactly what each of the operations do? I specifically need to know if any of them will return data sources (not mxd, but the actual source geodatabase).

    Reply
  2. iamlaksh1

    Hello, Will this clear REST cache automatically?? if not how to add this to script?. I want to make some changes in MXD, restart the services and clear the cache

    Reply
    1. John H

      This tool does not have the functionality to clear the REST cache automatically – it has a limited number of operations. However at ArGIS 10.1 for Server, the Cache is automatically cleared following the publishing of a service, so this will no longer be a problem.

      Reply

Got something to say?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s