AnsweredAssumed Answered

Stopping and Starting Services in Portal via Python

Question asked by brianmcleer on Jan 8, 2020
Latest reply on Jan 9, 2020 by agelfert

Trying to start/stop specific services. Using the article at How To: Stop GIS services using ArcGIS API for Python, I tried using the code but keep receiving an error message below posted code. I am running this script in IDLE (ArcGIS Pro). Using just IDLE for ArcGIS Desktop did not have the necessary modules. 

 

from arcgis.gis import GIS
import arcgis.gis.admin
gis = GIS("https://url.to.com/portal", "Username", "Password", verify_cert=False)
services = gis_servers.services.list()
#To stop specific service(s)
for service in services:
for service in server.services.list():
if service.properties.serviceName == "SampleWorldCities":
service.stop()

 

Error Message: 

 

Traceback (most recent call last):
File "Z:\Temp\Brian\test.py", line 5, in <module>
services = gis_servers.services.list()
NameError: name 'gis_servers' is not defined

Outcomes