# `PhoenixKit.ScheduledJobs.Workers.ProcessScheduledJobsWorker`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.165/lib/phoenix_kit/scheduled_jobs/workers/process_scheduled_jobs_worker.ex#L1)

Oban worker that processes pending scheduled jobs.

This worker runs every minute via Oban's cron plugin and processes all
scheduled jobs that are due for execution. It replaces the single-purpose
`PublishScheduledPostsJob` with a universal job processor.

## Configuration

Add to your Oban cron configuration:

    config :your_app, Oban,
      plugins: [
        {Oban.Plugins.Cron,
         crontab: [
           {"* * * * *", PhoenixKit.ScheduledJobs.Workers.ProcessScheduledJobsWorker}
         ]}
      ]

## Behavior

1. Runs every minute
2. Queries all pending jobs where `scheduled_at <= now`
3. Orders by priority (DESC) then scheduled_at (ASC)
4. For each job, loads the handler module and calls `execute/2`
5. Marks jobs as executed or failed based on result
6. Logs summary of processed jobs

## Error Handling

- Jobs that fail are marked with incremented attempt count
- After max_attempts, job status changes to "failed"
- Exceptions are caught, logged, and treated as failures
- Worker itself always returns :ok to prevent Oban retries

---

*Consult [api-reference.md](api-reference.md) for complete listing*
