Setting Up Schedulers
To run the archive, purge, and cleanup services of the Audit Subsystem automatically, configure the corresponding Scheduler Thing to trigger the operation. To specify the interval for a given service to run, use a CRON expression The CRON expression makes these intervals flexible. For example. you may want to archive online audit data daily, every other day, every two days, or weekly.
The Direct Persistence and Data Table have schedulers specific to their services. Even if schedulers for both implementations are enabled and configured, only one of them will execute the archive service. More specifically, only the service corresponding to the active implementation of the AuditSubsystem will run. By default, if the other scheduler is active, it will try to run the archive service, but since its implementation is disabled, it only logs a WARN message, that it tried to execute the archive service but failed since the other implementation is enabled.
To set up a schedule for automatic archiving, purging, or cleanup of audit data:
1. From ThingWorx Composer, browse Modeling > Schedulers and when the list of Schedulers appears, select the scheduler for the service:
Audit Service
Scheduler Thing
Direct Persistence
Data Table
Never disable the purge scheduler. Doing so prevents the system from periodically copying the online audit data to the offline repository and then deleting it. Allowing the online data to accumulate to a very high amount without periodic purge operations may eventually bring the platform down.
2. In the General Information page for the scheduler, set these properties:
Run As User — This property specifies the user context within which the ScheduledEvent is fired. In addition, subscriptions to that event also run in that user context. It is recommended that you set it to Administrator.
Enabled — Specifies whether the scheduler is enabled. Select the check box to enable or disable the scheduler.
3. In the Schedule field, click the pen icon to display the configuration page for the scheduler:
4. Set up the schedule, and click Done to save the CRON string and close the page.
5. Click Save to save your changes.
The scheduler for the corresponding service will automatically trigger the service based on this schedule.
The schedulers have a property that shows the last run time of a scheduled job, called LastArchivedTime for the Data Table implementation archive service or LastArchivedTimeDirectPersistence for the Direct Persistence implementation archive service. After every successful run of a scheduled job, the system updates this property. Note that although it is possible, this property should never be edited manually.
Was this helpful?