After publishing routing services from a network dataset configured with live traffic, it is essential to ensure that the live traffic data used by these services is updated at regular intervals. This can be achieved by following the workflow outlined below:
You need to configure a Python script to run every two minutes using crontab. This built-in command-line utility allows users to schedule tasks to run automatically at specified intervals. The Python script configured to run via crontab requires the following prerequisites:
- You should configure the crontab for the operating system user designated as the ArcGIS Server account.
- The Python script requires Python version 3.9 or later. It is important to use a version of Python that is not included with ArcGIS Server; instead, you should use the Python version that is natively available on your operating system.
- The Python environment should have the requests module installed.
Update live traffic data every two minutes by running a Python script via crontab. The example assumes that the ArcGIS Server installation location is /arcgis/server.
(crontab -l; echo "*/2 * * * * /usr/bin/python3 /arcgis/server/framework/runtime/ArcGIS/Resources/ArcToolBox/Services/routingservices/update_traffic_cache_scheduler.py >/dev/null 2>&1") | crontab -
Note:
The above steps must be performed on every machine in a multimachine ArcGIS Server site.
The Python script generates a log file named update_traffic_cache_scheduler.log, which is stored in the default folder where ArcGIS Server writes its logs such as <ArcGIS Server installation directory>/arcgis/server/usr/logs. You can check this log file to determine whether any errors occurred during the implementation of the script.
Check live traffic data status
After you have set up the live traffic data to update at regular intervals, you can verify whether the traffic data is updating successfully by running the GetLiveTrafficStatus tool within the NetworkAnalysisUtilities geoprocessing service. This service is available in the same folder where other routing services were published. For example, if the routing services were published to a service folder named Routing, the URL to the GetLiveTrafficStatus tool will be https://machine.example.com/webadaptorname/rest/services/Routing/NetworkAnalysisUtilities/GPServer/GetLiveTrafficStatus. The output from GetLiveTrafficStatus can be used to check whether the traffic data is successfully updating.
Example output from the GetLiveTrafficStatus tool shows that the last update was successful since isLastUpdateSuccessful is true. If there are errors during the last update, isLastUpdateSuccessful is set to false, and the reasons for failure are returned as part of the lastUpdatedMessages property.
{
"results": [
{
"paramName": "status",
"dataType": "GPString",
"value": {
"cachePath": "C:\\NA\\RoutingServices\\traffic-cache\\openlr.3a795f46cf77473fb1dc606ef73a2cb5",
"isLastUpdateSuccessful": true,
"isUpdateInProgress": false,
"roadClosuresDataAvailable": true,
"roadClosuresDataSize": 64427318,
"speedDataAvailable": true,
"speedsDataSize": 3977019303,
"tempDataSize": 365970076,
"trafficCacheStatus": {
"endTimeWindow": 1744065360000,
"lastCreatedFileNames": [
"speeds.20250407132800.1.ff.dat",
"speeds.20250407213200.1.nff.dat",
"road_closures.20250407213200.1.dat",
"speeds.20250407213200.info.dat",
"speeds.20250407213600.info.dat"
],
"lastDecodingElapsedTime": 0,
"lastRemovedFileNames": [
"speeds.20250407173200.info.dat",
"road_closures.20250407173200.1.dat"
],
"lastUpdatedElapsedTime": 11582,
"lastUpdatedMessages": [
],
"lastUpdatedTime": 1744062137882,
"remainingSpeedLocationsToMatch": 0,
"roadClosureLocationsCount": 23153,
"selectedTrafficDataRegions": [
"CAN",
"MEX",
"USA_N",
"USA_SW",
"USA_SE",
"USA_M"
],
"speedLocationsCount": 1468719,
"startTimeWindow": 1744047330000
}
}
}
],
"messages": [
]
}