How to update the next scan date/time of a Discovery Agent
Purpose
It's possible to set the next scan date/time for each scan settings via the Discovery tool as shown in the screenshot below. However, it's not possible to set/update the same for a Discovery Agent on the UI. This guide is to show you where the setting can be found and how we could update it.
Solution
As per Set up Discovery Agent, the Agent is ready to be deployed and ran without any changes required. In some situations, you might wish to have the Agent running the scan at a specific interval starting a specific date and time. These settings are in the Agent.cfg file located in the installation folder of the Agent. A common path of the Agent installation folder is C:\Program Files\Atlassian\Discovery Agent.
<?xml version="1.0" encoding="utf-8"?><Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ScanLogLevel>Normal</ScanLogLevel><NextScanDate>2021-11-10T13:04:15.4476259+01:00</NextScanDate><ScanInterval>24</ScanInterval><AgentPort>51337</AgentPort><JustUseFirstIP>false</JustUseFirstIP><DeleteLogsAfter>7</DeleteLogsAfter><DisableTCPListener>false</DisableTCPListener><DirectCopyPath /><SFTPSettings><TransferReties>5</TransferReties><TranserRetryInterval>30</TranserRetryInterval></SFTPSettings></Settings>
To update the next scan date/time,
- Open the Agent.cfg file in a text editor.
- Set the desired date and time between <NextScanDate></NextScanDate>.
XSD format (YYYY-MM-DDThh:mm:ss(+|-)hh:mm) should be used for the next scan date. For example, the next scan date and time should be November 10th, 2021 at 11pm UTC+1. This should be written as 2021-11-10T23:00:00+01:00.
- Save the Agent.cfg file for the new next scan date to take effect.
- To check if the new scan date is correctly saved, you can close the Agent.cfg file and open it again in a text editor to check the next scan date.
You could also check the latest log in the logs folder in the Agent installation path. If the date is invalid, an error as shown below will appear and the previously saved date will be taken from the Agent.bak file which is a backup of the configuration file.
11/10/2021 11:29:35 AM : Error loading settings. 11/10/2021 11:29:35 AM : Exceptions: 11/10/2021 11:29:35 AM : There is an error in XML document (1, 234). at Insight.Discovery.Tools.ObjectSerializer.DeserializeObject[T](String file, SerializeType sType) in C:\SourceCode\discovery_repo\DiscoTools\ObjectSerializer.cs:line 127 at Insight.Discovery.Agent.Logic.Settings.TryLoad(String settingsFile) in C:\SourceCode\discovery_repo\Discovery_Agent\Logic\Settings.cs:line 109 11/10/2021 11:29:35 AM : The string '2021-11-12T01:00+01:00' is not a valid AllXsd value. at System.Xml.Schema.XsdDateTime..ctor(String text, XsdDateTimeFlags kinds) at System.Xml.XmlConvert.ToDateTime(String s, XmlDateTimeSerializationMode dateTimeOption) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSettings.Read4_Settings(Boolean isNullable, Boolean checkType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSettings.Read5_Settings() 11/10/2021 11:29:35 AM : Could not load settings, settings are reseted from backup file.