MID Server File Cleaner
Summarize
Summary of MID Server File Cleaner
The MID Server File Cleaner is a built-in monitor thread within the MID Server that automatically cleans up old files to maintain optimal performance. It manages the size and quantity of files in the MID Server install folder by deleting files and empty folders that have not been accessed for more than 30 days. This cleanup helps prevent performance degradation and keeps the MID Server environment orderly.
Show less
The File Cleaner runs automatically on MID Server startup and then every 24 hours thereafter. You can also force it to run immediately by restarting the MID Server service.
Key Features
- Targeted Cleanup: Deletes files and empty folders from specific directories, including:
\agent\import\agent\export(used by Export Set feature)\agent\work\monitors\ECCSender\outputerror(for ECC input payloads that cannot be inserted)\agent\work\monitors\ECCSender\outputoversize(for payloads exceeding size limits)\agent\logs(specifically JFR Dumps from Utah release)
- Logging: The MID Server agent log records when the File Cleaner monitor starts and stops. Detailed debug logging for each scan can be enabled via the
mid.log.level=debugparameter. However, individual file or folder deletions are not logged. - Configurable: The File Cleaner can be completely disabled by setting the configuration parameter
mid.filecleaner.disabled=true. This parameter can be added through the MID Server form's Configuration Parameters list or manually in the MID Server'sconfig.xmlfile.
Practical Implications for ServiceNow Customers
- The File Cleaner ensures the MID Server remains performant by preventing accumulation of outdated files, which could otherwise cause storage and processing issues.
- Customers using Export Sets should implement custom processes to move or archive export files promptly, as these files are only retained temporarily in the MID Server's export folder before being cleaned.
- Disabling the File Cleaner should be done cautiously and only if there is a clear process in place to manage MID Server file storage to avoid performance issues.
- Enabling debug logging for the File Cleaner is useful for troubleshooting or confirming cleanup operations during MID Server maintenance.
Related Configuration and Maintenance
- Control the File Cleaner behavior via the
mid.filecleaner.disabledparameter. - Restart the MID Server service to trigger an immediate File Cleaner run.
- Refer to other MID Server parameters and system requirements for comprehensive MID Server management and optimization.
A monitor thread runs in the MID Server to clean up old files, to keep the size and quantity of files within the install folder manageable, and to prevent performance issues with the MID Servers.
Files and empty folders within the following folders may be deleted by this MID File Cleaner. Files last accessed more than 30 days ago are deleted.
It runs on startup, and then every 24 hours after that. You can force the File Cleaner to run by restarting the MID Server service.
Folders/files cleaned:
- \agent\import
- \agent\export - Used by the Export Set feature.
- \agent\work\monitors\ECCSender\output_error - Used since San Diego for ECC input payloads that cannot be inserted for any reason (see PRB1521761/KB0995569).
- \agent\work\monitors\ECCSender\output_oversize - Used since Eureka/Fuji for saving copies of payloads that are not sent to the instance because they are larger than the limit set by mid.eccq.max_payload_size, which defaults to 20000000 bytes (see PRB598334)
- \agent\logs - Specifically JFR Dumps (Utah release)
Logging
The MID Server agent log shows this monitor starting and shutting down with the MID Server.
2022-10-21T13:08:58.330+0200 INFO (MIDServer) [Main:265] Initializing MID Server
2022-10-21T13:10:36.527+0200 INFO (StartupSequencer) [Monitors:307] Enabling monitor: FileCleanerMonitor
...
2022-10-24T09:29:35.193+0200 INFO (MIDServer) [MIDServerState:160] MID Server stopping
2022-10-24T09:29:38.591+0200 INFO (MIDServer) [Instance:928] interrupting thread FileCleanerMonitor.21600
To see exactly when it runs, enable debug with parameter
mid.log.level=debug.
2022-11-17T02:49:13.201-0800 DEBUG (FileCleanerMonitor.21600) [AFileCleaner:103] Scanning directory to delete files: C:\...\agent\import
2022-11-17T02:49:13.201-0800 DEBUG (FileCleanerMonitor.21600) [AFileCleaner:103] Scanning directory to delete files: C:\...\agent\export
2022-11-17T02:49:13.201-0800 DEBUG (FileCleanerMonitor.21600) [AFileCleaner:103] Scanning directory to delete files: C:\...\agent\work\monitors\ECCSender\output_error
2022-11-17T02:49:13.201-0800 DEBUG (FileCleanerMonitor.21600) [AFileCleaner:103] Scanning directory to delete files: C:\...\agent\work\monitors\ECCSender\output_oversize
2022-11-17T02:49:13.201-0800 DEBUG (FileCleanerMonitor.21600) [AFileCleaner:103] Scanning directory to delete files: C:\...\agent\logs
There is no logging for individual file/folder deletes.
Disabling the MID File Cleaner
Export Sets write files to the MID Server agent\export folders. The idea is then that a custom implementation on the customer side takes those files and moves them elsewhere, so that these files only need to remain in the MID Server application's install directory for a short time.
The MID File Cleaner can be disabled completely for all folders, by adding the MID Server Configuration Parameter mid.file_cleaner.disabled=true. When the parameter is not present, which is the out-of-box state, it defaults to false, and the file cleaner runs.
On the MID Server form, click New on the "Configuration Parameters" related list, select mid.file_cleaner.disabled, and enter the value "true".
This can also be manually added to the config.xml file: <parameter
name="mid.file_cleaner.disabled" value="true"/>. See MID Server parameters for more information.