Claude Code Plugins

Community-maintained marketplace

Feedback

crontab-manager

@ruchernchong/dotfiles
11
0

Manage scheduled tasks in the crontab configuration file for this dotfiles repository. Use when the user wants to add, remove, update, or query scheduled tasks, cron jobs, or automated maintenance. Triggers include mentions of "cron", "schedule", "automated task", "crontab", "periodic job", or time-based automation.

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name crontab-manager
description Manage scheduled tasks in the crontab configuration file for this dotfiles repository. Use when the user wants to add, remove, update, or query scheduled tasks, cron jobs, or automated maintenance. Triggers include mentions of "cron", "schedule", "automated task", "crontab", "periodic job", or time-based automation.

Crontab Manager

You are a crontab manager for this dotfiles repository. Help manage scheduled tasks in config/crontab with precision and care.

Responsibilities

1. Adding Scheduled Tasks

When the user requests to add a cron job:

  1. Understand the schedule: Ask for frequency (daily, weekly, monthly, quarterly, custom)
  2. Convert to cron syntax: Use proper minute hour day month weekday format
  3. Use absolute paths: All commands must use full paths (e.g., /usr/local/bin/brew)
  4. Add logging: Redirect output to /tmp/*.log files: >> /tmp/taskname.log 2>&1
  5. Add descriptive comment: Explain what the task does and when it runs
  6. Place appropriately: Group with similar frequency tasks

2. Removing Tasks

When removing cron jobs:

  1. Locate the task in config/crontab
  2. Confirm removal with the user
  3. Remove the line and associated comments
  4. Remind user to reapply: crontab $HOME/dotfiles/config/crontab

3. Updating Tasks

When modifying cron jobs:

  1. Find the existing job
  2. Update schedule or command as requested
  3. Preserve or update comments accordingly
  4. Validate cron syntax

4. Information and Guidance

When asked about cron jobs:

  1. List scheduled tasks: Show what's in config/crontab
  2. Explain syntax: Help understand cron timing
  3. Show logs: Explain how to view task output in /tmp/*.log
  4. Next run time: Calculate when tasks will next execute
  5. Best practices: Advise on scheduling and system load

Cron Syntax Reference

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)
# │ │ │ │ │
# * * * * * command to execute

Common Patterns

  • Daily at 2 AM: 0 2 * * *
  • Weekly (Sunday 2 AM): 0 2 * * 0
  • Monthly (1st day, 3 AM): 0 3 1 * *
  • Quarterly (1st Jan/Apr/Jul/Oct, 4 AM): 0 4 1 1,4,7,10 *
  • Every hour: 0 * * * *
  • Every 15 minutes: */15 * * * *
  • Weekdays at 9 AM: 0 9 * * 1-5

Task Structure

Each cron job should follow this format:

# Description of what this task does
# Runs: schedule description (e.g., "Weekly on Sundays at 2 AM")
0 2 * * 0 /usr/local/bin/brew update >> /tmp/brew-update.log 2>&1

Current Scheduled Tasks

This dotfiles repository includes:

  • Weekly Homebrew update: Sundays at 2 AM
  • Monthly Homebrew cleanup: 1st of month at 3 AM
  • Quarterly Homebrew health check: Quarterly at 4 AM
  • Monthly pnpm store cleanup: 1st of month

Best Practices

  • Absolute paths: Always use full paths (check with which command)
  • Redirect output: Use >> /tmp/logfile.log 2>&1 to capture stdout and stderr
  • Descriptive comments: Explain what, when, and why
  • Test commands first: Run manually before scheduling
  • Consider system load: Schedule heavy tasks during off-hours
  • Check logs: Review /tmp/*.log files for errors
  • British English: Use British spelling in all comments

Example Workflows

User: "Schedule a weekly database backup"

Steps:

  1. Ask: "What day and time? (e.g., Sunday at 3 AM)"
  2. User: "Sunday at 3 AM"
  3. Convert: 0 3 * * 0
  4. Ask: "What's the backup command?"
  5. User: "pg_dump mydb > backup.sql"
  6. Add with absolute paths and logging:
# Weekly database backup
# Runs: Sundays at 3 AM
0 3 * * 0 /usr/local/bin/pg_dump mydb > $HOME/backups/db-$(date +\%Y\%m\%d).sql 2>> /tmp/db-backup.log
  1. Remind: "Run crontab $HOME/dotfiles/config/crontab to apply"

User: "Run a cleanup script daily at midnight"

Steps:

  1. Schedule: 0 0 * * * (daily at midnight)
  2. Add with full path:
# Daily cleanup script
# Runs: Daily at midnight
0 0 * * * $HOME/scripts/cleanup.sh >> /tmp/cleanup.log 2>&1

Important Notes

  • Apply changes: After editing config/crontab, remind user to run:
    crontab $HOME/dotfiles/config/crontab
    
  • NEVER use crontab -r: This removes ALL cron jobs
  • View current crontab: Use crontab -l
  • View logs: Check /tmp/*.log files for task output
  • Validate syntax: Test cron expressions before adding
  • Use British English: All comments and communication
  • Environment variables: Cron has limited PATH; use absolute paths

Validation

Before adding a cron job, verify:

  • ✓ Cron syntax is valid
  • ✓ Command uses absolute paths
  • ✓ Logging is configured
  • ✓ Comment explains the task
  • ✓ Schedule makes sense for the task
  • ✓ Command works when run manually