> ## Documentation Index
> Fetch the complete documentation index at: https://help.propops.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Cron Job Management

> Set up and operate PropOps Web background jobs with n8n, secure webhook calls, retention controls, and audit verification.

This guide explains how to run PropOps Web cron jobs through n8n, verify execution, and confirm retention/audit behavior.

***

## 1. Confirm prerequisite settings

In your environment configuration, ensure the following are set:

* `CRON_WEBHOOK_TOKEN`
* `GDPR_ACTIVITY_LOG_RETENTION_MONTHS`
* `GDPR_REPORT_FILE_RETENTION_HOURS`

Use conservative values in production and document policy decisions internally.

***

## 2. Create or review n8n schedules

For each background task, configure an n8n workflow with:

1. **Schedule Trigger** node
2. **HTTP Request** node (`POST`)
3. URL set to your cron webhook endpoint: `/api/cron/webhook`
4. Header: `X-Webhook-Token: <your token>`
5. Body fields:
   * `script`: target cron filename
   * `triggered_by`: `n8n`

Example body:

```json theme={null}
{
  "script": "cleanup_gdpr_data.php",
  "triggered_by": "n8n"
}
```

***

## 3. Use approved script names only

The cron webhook accepts only allowlisted script names. If a script is not approved, the webhook returns an authorization error.

If you add a new cron script:

1. add the script file
2. add it to webhook allowlist
3. create/update n8n workflow
4. define concurrency behavior where applicable

***

## 4. Recommended scheduling pattern

Use frequent schedules for lightweight maintenance and less frequent schedules for heavy work.

Typical examples:

* Session cleanup: hourly
* GDPR cleanup: hourly or daily (based on policy strictness)
* API history cleanup: daily
* Commit archive purge: daily
* Heavy optimize/analyze passes: off-peak windows

***

## 5. Validate retention behavior

After schedule changes:

1. run the workflow manually once
2. confirm cron log file updates
3. confirm expected rows/files are removed
4. confirm activity entry exists in `user_activity_log`

For GDPR/SAR policy, verify generated report files expire according to `GDPR_REPORT_FILE_RETENTION_HOURS`.

***

## 6. Verify audit trail

For cleanup/purge jobs, confirm an activity record exists with:

* activity type for the job
* script name
* deleted counts
* execution type as `cron`

This is required for operational and compliance traceability.

***

## 7. Troubleshooting

If a job does not run:

* check n8n workflow status and last execution
* verify webhook token header
* verify script name is allowlisted
* check cron script log file in `cron/logs` or `logs`
* test script directly via CLI for syntax/runtime issues

***

## Related pages

* Cron capability overview: [/features/cron-jobs](/features/cron-jobs)
* Admin panel controls: [/features/admin](/features/admin)
* Integrations setup: [/configuration/integrations](/configuration/integrations)
* Webhook API reference: [/api/webhooks#cron-webhook](/api/webhooks#cron-webhook)
