Skip to main content
skill CX Codex

cron-scheduling — Claude Code skill: schedules and setup

The cron-scheduling skill covers recurring jobs with cron, node-cron, Spring @Scheduled, and APScheduler. Use it when a project needs timed or periodic execution.

MIT 162 installs ★ 50 updated 2026-10-23

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add claude-dev-suite/claude-dev-suite --skill cron-scheduling -a claude-code
Open on GitHub

What cron-scheduling does

The skill explains five-part cron syntax and applies it to node-cron, Spring @Scheduled, and APScheduler. Its examples cover calendar-based runs, fixed intervals, delays after completion, and explicit timezone settings.

It also covers distributed locks with Redlock and ShedLock, error handling, execution monitoring, logging, and graceful shutdown. A multi-instance deployment can run the same task more than once without a lock. Heavy queue work belongs in job-queues rather than inside a cron callback.

What it helps with

  • write a cron expression for a recurring run
  • schedule Node.js work with node-cron
  • configure Java jobs with Spring @Scheduled
  • run asynchronous Python tasks through APScheduler
  • stop multiple instances from duplicating a scheduled job

Example prompts for the agent

  • Create a cron expression that runs cleanup on weekdays at 9:00.
  • Add a node-cron task that syncs external data every 5 minutes.
  • Show how to guard an hourly report with Redlock across multiple instances.

How to install cron-scheduling

1Skills CLI (Vercel)

npx skills add claude-dev-suite/claude-dev-suite --skill cron-scheduling -a claude-code

2Manually: put the files in place

~/.claude/skills/cron-scheduling/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cron-scheduling/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about cron-scheduling

How do I install cron-scheduling in Claude Code?

Run npx skills add claude-dev-suite/claude-dev-suite --skill cron-scheduling -a claude-code. The skill file is placed at ~/.claude/skills/cron-scheduling/SKILL.md.

What does cron-scheduling do?

It helps create cron expressions and recurring jobs for node-cron, Spring @Scheduled, and APScheduler. It also covers locking patterns for scheduled work shared by multiple instances.

How can I prevent duplicate cron runs across instances?

Use a distributed lock such as Redlock in Node.js or ShedLock with Spring. Without one, separate instances can execute the same scheduled task at the same time.

Source text

SKILL.md · MIT
---
name: cron-scheduling
description: |
  Cron and scheduled task management. node-cron, cron expressions, Spring
  @Scheduled, APScheduler (Python), and distributed scheduling patterns.

  USE WHEN: user mentions "cron", "scheduled task", "cron job", "node-cron",
  "@Scheduled", "APScheduler", "periodic task", "crontab"

  DO NOT USE FOR: job queues with workers - use `job-queues`;
  one-off delayed tasks - use `job-queues`
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Cron Scheduling

## Cron Expression Syntax

```
┌─────── minute (0-59)
│ ┌────── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌──── month (1-12)
│ │ │ │ ┌─── day of week (0-7, 0 and 7 = Sunday)
│ │ │ │ │
* * * * *
```

| Expression | Schedule |
|------------|----------|
| `0 * * * *` | Every hour |
| `*/15 * * * *` | Every 15 minutes |
| `0 9 * * 1-5` | Weekdays at 9:00 AM |
| `0 0 1 * *` | First day of month, midnight |
| `0 */6 * * *` | Every 6 hours |

## Node.js (node-cron)

```typescript
import cron from 'node-cron';

// Run every day at 2:00 AM
cron.schedule('0 2 * * *', async () => {
  console.log('Running daily cleanup...');
  await cleanupExpiredSessions();
}, {
  timezone: 'America/New_York',
});

// Run every 5 minutes
cron.schedule('*/5 * * * *', async () => {
  await syncExternalData();
});
```

### With Distributed Locking (prevent duplicate runs)

```typescript
import { Redlock } from 'redlock';

const redlock = new Redlock([redis]);

cron.schedule('0 * * * *', async () => {
  let lock;
  try {
    lock = await redlock.acquire(['cron:hourly-report'], 60000);
    await generateHourlyReport();
  } catch (err) {
    if (err instanceof Redlock.LockError) return; // Another instance has the lock
    throw err;
  } finally {
    await lock?.release();
  }
});
```

## Spring @Scheduled (Java)

```java
@Component
@EnableScheduling
public class ScheduledTasks {

    @Scheduled(cron = "0 0 2 * * *") // Daily at 2 AM
    public void dailyCleanup() {
        sessionRepo.deleteExpired();
    }

    @Scheduled(fixedRate = 300000) // Every 5 minutes
    public void syncData() {
        externalService.sync();
    }

    @Scheduled(fixedDelay = 60000) // 60s after last completion
    public void processQueue() {
        queueService.processNext();
    }
}
```

### Distributed Scheduling (ShedLock)

```java
@Scheduled(cron = "0 */10 * * * *")
@SchedulerLock(name = "syncInventory", lockAtLeastFor = "5m", lockAtMostFor = "10m")
public void syncInventory() {
    inventoryService.syncAll();
}
```

## Python (APScheduler)

```python
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.cron import CronTrigger

scheduler = AsyncIOScheduler()

@scheduler.scheduled_job(CronTrigger(hour=2, minute=0))
async def daily_cleanup():
    await cleanup_expired_sessions()

@scheduler.scheduled_job('interval', minutes=5)
async def sync_data():
    await sync_external_data()

scheduler.start()
```

## Anti-Patterns

| Anti-Pattern | Fix |
|--------------|-----|
| Cron on multiple instances without locking | Use distributed lock (Redlock, ShedLock) |
| Long-running cron blocks next run | Use job queue for heavy work |
| No error handling in cron | Wrap in try-catch, log errors, alert |
| Hardcoded schedule | Use environment variable or config |
| No monitoring of cron execution | Log start/end times, track failures |

## Production Checklist

- [ ] Distributed locking for multi-instance deployments
- [ ] Error handling with alerting
- [ ] Execution time monitoring
- [ ] Timezone explicitly set
- [ ] Graceful shutdown (finish current job)
- [ ] Cron expressions documented

© claude-dev-suite · MIT · claude-dev-suite/claude-dev-suite

Similar skills

All skills for Automation and no-code: n8n, Zapier, Make →

From the same set14

The whole set →
token-optimization token-optimization teaches agents to minimize token usage when calling MCP tools and external APIs. Keeps context clean by enforcing limits and compact responses. CX Codex +1 354installs owasp-top-10 This skill guides OWASP Top 10:2025 security reviews, covering access control, injection, cryptography, supply-chain risks, and exception handling. CX Codex +1 330installs webrtc WebRTC skill for P2P communication: video calls, screen sharing, data channels. Writes signaling logic, configures ICE/STUN/TURN, integrates SFU like LiveKit. CX Codex +1 217installs email-sending The email-sending skill covers transactional email, provider APIs, SMTP, and reusable templates. Use it when a project needs welcome messages, alerts, or password emails. CX Codex +1 188installs iec61131 A reference for IEC 61131-3 languages, PLC data types, and program structure. Use it when comparing control-language options or checking project exchange formats. CX Codex +1 154installs plsql A skill for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode: Oracle PL/SQL — procedures, functions, packages, triggers, cursors, collections and exception handling. CX Codex +1 106installs socket-io Guides your coding assistant through Socket.IO real-time features: namespaces, rooms, middleware auth, and Redis scaling. CX Codex +1 106installs sonarqube Configures code quality tracking with SonarQube and SonarCloud. Sets up scanner properties, quality gates, and CI/CD pipelines. CX Codex +1 106installs

Project sponsors

Companies that keep this analytics open