Built-in Jobs

From Obsidian Scheduler
Jump to navigationJump to search

Obsidian comes bundled with free jobs for common tasks. These are provided in addition to Scripting Jobs to reduce implementation and testing time for common job functions.

File Processing Jobs

These jobs are provided to provide common basic file operations, such as file cleanup (deletion) and archiving. These jobs can be used to reduce the amount of code your organization needs to write.

File Cleanup Job

Job Class: com.carfey.ops.job.maint.FileCleanupJob

This job deletes files in specified paths based on one or more file masks (using regular expressions).

It supports the following configuration options:

  • Abort on Deletion Failure (Boolean) - If deletion fails, should we fail the job?
  • Directory (1 or more Strings) - A directory to scan for files. If recursive processing is enabled, child directories are also scanned.
  • File Mask (0 or more Strings) - A regular expression that files must match to be deleted. This is based on java.util.regex.Pattern. To match all files, remove all configured values or use ".*" without quotes. If multiple values are used, files are eligible for deletion if they match any of the file masks.
  • File Size Minimum (String) - The minimum size in bytes a file must be to be deleted. File sizes can be specified in bytes, kilobytes, megabytes or gigabytes (e.g. 10b, 100kb, 20mb, 2gb).
  • File Size Maximum (String) - The maximum size in bytes a file must be to be deleted. File sizes can be specified in bytes, kilobytes, megabytes or gigabytes (e.g. 10b, 100kb, 20mb, 2gb).
  • Minimum Time Since Modified (String) - The minimum age of a file to be deleted, based on the modified time. This can be specified in seconds, minutes, hours and days (e.g. 10s, 5m, 24h, 2d).
  • Recursive (Boolean) - Whether files in subdirectories of the configured directories should be checked for matching files.

Customization

If you wish to tweak or customize behaviour of this job, it can be subclassed. The following methods may be overridden or extended by calling super methods:

  • onStart - Called on job startup.
  • onEnd - Called on job end, regardless of success or failure.
  • shouldDelete - Determines if a file should be deleted.
  • deleteMatchingFile - Deletes a matching file and saves a job result for its path.
  • matchesAge - Determines if a file matches any age conditions (i.e. Minimum Time Since Modified), or true if none are configured.
  • matchesMask - Determines if a file matches any configured file masks, or true if none are configured.
  • matchesSize - Determines if a file matches size conditions, or true if none are configured.
  • processDirectory - Enumerates files in configured directories and calls shouldDelete and deleteMatchingFile as necessary.

Maintenance Jobs

These jobs are provided to help maintain the Obsidian installation.

Job History Cleanup Job

Job Class: com.carfey.ops.job.maint.JobHistoryCleanupJob

This job will delete job history and related records beyond a configurable age in days. This is useful for keeping the database compact and clearing out old, unneeded data.

The value for maxAgeDays corresponds to the maximum age for records to retain. By default it is set to 365, but you may configure it to any desired value.

Note: We recommend high volume users schedule the job weekly or less frequently and to schedule it for a non-peak time.

Log Cleanup Job

Job Class: com.carfey.ops.job.maint.LogCleanupJob

This job will delete log database records beyond a configurable age in days. This is useful for keeping the database compact and clearing out old, unneeded data.

The value for maxAgeDays corresponds to the maximum age for records to retain. By default it is set to 365, but you may configure it to any desired value.

The value for level corresponds to the logging level of events to delete. You may specify multiple values, and the "ALL" option will result in all records matching the age setting being deleted. Valid levels to configure are: FATAL, ERROR, WARNING, INFO, DEBUG, and TRACE.

It is common to only delete lower severity level events, such as INFO, DEBUG, and TRACE, but retain higher severity messages.

Note: We recommend high volume users schedule the job weekly or less frequently and to schedule it for a non-peak time.