Skip to content
Back to skills

Cron Job

ASecurity

Creates a cron job with error handling, logging, locking, and monitoring

  • 10 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 1, 2026
ai-agentsbashnodeexpresstesting

Security analysis

A100/100

Scanned June 1, 2026

npx -y skills add berkcangumusisik/claude-code-practices --skill cron-job --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cron Job?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cron Job
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/berkcangumusisik-cron-job/badge)](https://www.skillsdirectory.com/skills/berkcangumusisik-cron-job)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cron-job
description: Creates a cron job with error handling, logging, locking, and monitoring
argument-hint: <job-description> [schedule]
user-invocable: true
allowed-tools: Read Glob Edit
effort: low
---

## Create Cron Job

Job: **$1**
Schedule: **$2** (cron expression, e.g., `0 * * * *` = every hour)

1. Detect scheduler:
```bash
cat package.json | grep -E '"node-cron"|"cron"|"@nestjs/schedule"|"bullmq"|"pg-boss"'
```

2. Generate the job:
```ts
import cron from 'node-cron'
import { logger } from '@/lib/logger'

const JOB_NAME = '$1'

cron.schedule('$2', async () => {
  const startTime = Date.now()
  logger.info({ job: JOB_NAME }, 'Starting')

  // Distributed lock (prevent concurrent runs)
  const lock = await acquireLock(JOB_NAME, ttlSeconds: 300)
  if (!lock) {
    logger.warn({ job: JOB_NAME }, 'Already running, skipping')
    return
  }

  try {
    await runJob()
    logger.info({ job: JOB_NAME, duration: Date.now() - startTime }, 'Completed')
  } catch (error) {
    logger.error({ job: JOB_NAME, error }, 'Failed')
    // Alert if needed
  } finally {
    await releaseLock(JOB_NAME)
  }
})
```

3. Include:
   - Distributed locking (Redis or DB-based) to prevent concurrent execution
   - Structured logging with duration
   - Alert on failure (if project has alerting)
   - Graceful shutdown handling
   - Manual trigger endpoint for testing

4. Add to job registry so all jobs are visible in one place.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…