Skip to content
Back to skills

Cron

BSecurity

Schedule recurring tasks with cron on Linux/macOS. Use when a user asks to run scripts on a schedule, set up automated backups, schedule data processing, or configure periodic tasks on a server.

  • 142 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 27, 2026
toolsgoshellbashsqlnodeexpressdatabasedevops

Works with

  • terminal

Security analysis

B85/100
  • highCreates or modifies cron jobs for persistent execution
  • highCreates or modifies cron jobs for persistent execution

Pro scans all 2 files and shows the line behind each finding

Scanned May 27, 2026

npx -y skills add TerminalSkills/skills --skill cron --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cron?

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

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

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
description: >-
  Schedule recurring tasks with cron on Linux/macOS. Use when a user asks to
  run scripts on a schedule, set up automated backups, schedule data processing,
  or configure periodic tasks on a server.
license: Apache-2.0
compatibility: 'Linux, macOS'
metadata:
  author: terminal-skills
  version: 1.0.0
  category: devops
  tags:
    - cron
    - scheduling
    - automation
    - linux
    - tasks
---

# cron

## Overview

cron is the standard Unix task scheduler. Define schedules with cron expressions (minute, hour, day, month, weekday) to run scripts automatically. Used for backups, log rotation, data sync, health checks, and any recurring task.

## Instructions

### Step 1: Crontab Basics

```bash
# Edit your crontab
crontab -e

# Format: minute hour day month weekday command
# ┌─── minute (0-59)
# │ ┌─── hour (0-23)
# │ │ ┌─── day of month (1-31)
# │ │ │ ┌─── month (1-12)
# │ │ │ │ ┌─── day of week (0-7, 0=Sun)
# │ │ │ │ │
# * * * * * command
```

### Step 2: Common Schedules

```bash
# Every day at 3 AM
0 3 * * * /opt/scripts/backup.sh

# Every hour
0 * * * * /opt/scripts/health-check.sh

# Every 15 minutes
*/15 * * * * /opt/scripts/sync-data.sh

# Monday to Friday at 9 AM
0 9 * * 1-5 /opt/scripts/daily-report.sh

# First day of every month at midnight
0 0 1 * * /opt/scripts/monthly-cleanup.sh

# Every Sunday at 2 AM
0 2 * * 0 /opt/scripts/weekly-maintenance.sh
```

### Step 3: Best Practices

```bash
# Always redirect output to a log file
0 3 * * * /opt/scripts/backup.sh >> /var/log/backup.log 2>&1

# Use full paths (cron has minimal PATH)
0 * * * * /usr/bin/node /opt/app/scripts/job.js

# Set environment variables
MAILTO=admin@example.com
PATH=/usr/local/bin:/usr/bin:/bin
SHELL=/bin/bash

0 3 * * * /opt/scripts/backup.sh
```

### Step 4: System Cron (root tasks)

```bash
# /etc/cron.d/app-maintenance — System-level cron file
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin

# Database backup as postgres user
0 3 * * * postgres pg_dump myapp > /backups/myapp-$(date +\%Y\%m\%d).sql

# Log rotation
0 0 * * * root /usr/sbin/logrotate /etc/logrotate.conf
```

## Guidelines

- Always use full paths in cron — the PATH is minimal.
- Redirect output to log files or `/dev/null` — unhandled output gets emailed.
- Use `crontab -l` to list, `crontab -e` to edit, `crontab -r` to remove all (careful!).
- For modern alternative with dependency tracking, use systemd timers.
- Test commands manually before putting them in cron.

Files in this skill

  • SKILL.md2.5 KB
  • _scores.json1.5 KB

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…