Old Content Notifier Job
This script will check the pages and their descendants returned from the CQL clause provided to determine if there are any inactive pages. If any inactive pages are found, a short report will be generated and emailed to all the users in the specified group.
An inactive page is defined as a page of a specified age where all descendants are also the same age or older. Adding a comment to a page will flag it as active.
The job will allow you to automatically notify content managers about inactive pages, for example:
On a specified space, find all the inactive pages older than 2 years with inactive descendants without the label 'ignore_inactive'. The CQL clause would look like this: space = SPACEKEY and type = page and lastModified < now('-104w') and label not in (ignore_inactive)
The job could potentially take a while to complete if casting a large net with your CQL clause.
This job will only operate on pages.
Follow these steps to set up the job:
- Navigate to General Configuration > ScriptRunner > Jobs.
- Select Create Job.
- Select Old Content Notifier.
- Enter a Name.
Select a User.
When the job runs, the user is logged as the one who made the change.You can create a user to assign for jobs like this. For example, ScriptRunner Bot User.
- Enter an Interval/Cron Expression.
Determine how often you want this job to run. You can select Show Examples to use an included expression or enter your own. You have two options for this field:- Interval: The easiest way to fill out this field is to enter an interval of minutes. For example, if you want the job to run every 30 minutes, enter 30. If you want it to run every 24 hours, enter 1440.
- Cron: If you need the job to run on a more detailed schedule, use a cron expression. For example, if you want it the job to run at 12:30 AM on Sundays, use the cron 0 30 0 ? * SUN. Another example is if you want the job to run every minute, use the cron 0 0/1 * 1/1 * ?.
- Interval: The easiest way to fill out this field is to enter an interval of minutes. For example, if you want the job to run every 30 minutes, enter 30. If you want it to run every 24 hours, enter 1440.
Enter a CQL Query to select pages you want the job to run on.
CQL tips
- CQL autocomplete is available for this job. Start typing to see possible CQL statements.
- Visit the CQL Guide for help with CQL.
- Select the Group you want to notify.
- Use the Content Age field to determine what items will be deleted.
- The Preset Filters are:
- Older than 6 months
- Older than 1 year
- Older than 2 years
You also have the option to select a Custom Filter, Older Than. If you select the Older Than value, a screen appears where you choose inputs.
The Older Than field must contain a value (which specifies a specific date) equal or greater than the date specified in the CQL 'lastModified' clause.
- The Preset Filters are:
- Click Add.
Your job now appears on the Jobs page of ScriptRunner. It will run when specified in the script, and you can choose to run it at other times. You can also enable and disable it.
Example
The following example configuration shows an old content notifier job which will run as the Admin user each Sunday morning just after midnight.
- For Name, enter Timed archival job 1 space a.
- Enter the admin User.
- For Interval/Cron Expression, enter 0 30 0 ? * SUN to run at 12:30 AM on Sundays.
- Enter the CQL Query of space = TS1 and type = page and lastModified <now("104") to run on all pages in a space with the space key TS1 which were modified over 2 years ago.
- Enter content-management for Group.
- For Content Age, select Older Than and then enter 104 Weeks in the fields that appear.
- Select Add.