Find Map Services Last Published Date?

1905
6
08-22-2017 06:54 PM
BenVan_Kesteren1
Regular Contributor

Hey All, 

Just wondering if anyone knows if it is possible to find the date a Map Service was last published to our GIS Server?

I currently automate the publishing of a MXD document to the Online Map Server, but I want to skip the update if the document (layer symbology, layer visibility etc.) has not been modified since it was last published. 

I have worked out how to detect file modification date no worries, but its the online map service I am unable to work out how to detect last published date.

Any ideas?

0 Kudos
6 Replies
shan_sarkar
Regular Contributor

Ben,

From what I understood, is your data changing (records are getting added or deleted) or your layers getting updated (new layers get added or existing layers get removed)

or are you adding new fields in the feature class used as layers in the MXD?


~Shan
0 Kudos
BenVan_Kesteren1
Regular Contributor

Sorry I should have made that clearer (I will edit original post), but I am meaning I am changing symbology etc, then re-publishing my map service. I want to find the last time the map service (sitting on the map server) was published.

Cheers

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Ben... you have this in the Python place... what do they use over in Server world since there is nothing in the arcpy tree

0 Kudos
JonathanQuinn
Esri Frequent Contributor

What about looking at the modified property of the item in ArcGIS Online?

Ex.

http://<org>.maps.arcgis.com/sharing/rest/content/items/<item>?f=json&token=<token>

The modified property will be in epoch time:

{...

modified=1497377330000,

...}

You can look at the last modified time stamp of the mxd and compare it to the modified property of the service.  If the mxd was modified significantly later, as it's unlikely they'll perfectly match up, then you can overwrite it.

deactivated-user-ChrisBeaudett
New Contributor III

From what I've found the last published date/time is not available from any of the APIs (service REST endpoint nor the admin API nor the Updated date in AGOL, for a layer item that references an on-prem AGS service).

From what I can tell the only way to resolve the last-published date/time for an AGS service is to 

browse the AGS server directory and get the timestamp on the \\AGS_SERVER_NAME\DRIVE$\arcgisserver\directories\arcgissystem\arcgisinput\FOLDER_NAME\SERVICE_NAME.MapServer folder, and/or on the MXD in the underlying folder at ...\extracted\v101\MXD_NAME.mxd.

Not ideal. Would be great if it was logged somewhere.

JonathanQuinn
Esri Frequent Contributor

The life cycle information can be used for that, (added at 10.5):

https://machine.domain.com:6443/arcgis/admin/services/MyService.MapServer/lifecycleinfos?f=pjson 

This will return information in Epoch time about when the service was created and last modified:

Ex.:

{
  "lifecycleinfos": [
    {
      "user": "",
      "timestamp": 1536190667304,
      "type": "created"
    },
    {
      "user": "",
      "timestamp": 1536190667380,
      "type": "started"
    }
  ],
  "lastmodified": 1536190667380
}