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?
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?
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
Ben... you have this in the Python place... what do they use over in Server world since there is nothing in the arcpy tree
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.
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.
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
}
Came here to find this answer, and Jonathan's is very good, and more pertinent to Python than what I'm about to add. But since some folks might come to this thread from a wider concern than just Python, I thought I'd add: if you log in to your REST admin pages (typically at https://{servername-URL}/arcgis/admin), then browse to the specific service lifecycle page, you get this information translated into human-readable time (ie not Epoch time). So, for me, this was easily readable at https://{server-url}/arcgis/admin/services/{foldername}/{servicename}.MapServer/lifecycleinfos