Automated summary
This skill explains how to schedule recurring tasks with cron on Linux and macOS, from cron expression syntax to production best practices.
Strengths
- Covers full cron expression syntax with a clear commented diagram
- Provides copy-ready examples for backups, health checks, reports, and cleanups
- Includes essential practices: absolute paths, log redirection, environment variables
- Shows both user crontabs and system-level cron files in /etc/cron.d
Limitations
- Does not cover classic pitfalls like escaping the % character in cron commands
- No discussion of timezones or differences between cron implementations
- Mentions systemd timers as an alternative but gives no concrete examples
Use when someone needs to automate a recurring task on a Linux or macOS server using cron.
Avoid it when scheduling requires task dependencies or a more modern scheduler such as systemd timers or a cloud orchestrator.
Security analysis
SafeThe skill provides educational guidance for using cron, including standard commands like crontab -e, crontab -l, and system cron configuration. It does not instruct destructive or exfiltrating actions; the mention of 'crontab -r' includes a warning to be careful, and all examples are legitimate scheduling tasks. No obfuscated payloads or network exfiltration are present.
No concerns found
How this analysis is madeExamples
Set up a cron job that runs my backup script every day at 3 AM and writes output to /var/log/backup.log.How do I schedule a script to run every 15 minutes with cron, using full paths so it works reliably?Create a system cron file in /etc/cron.d that dumps my Postgres database as the postgres user every night.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
# 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
# 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
# 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)
# /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 -lto list,crontab -eto edit,crontab -rto remove all (careful!). - For modern alternative with dependency tracking, use systemd timers.
- Test commands manually before putting them in cron.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/schedule-tasks-with-cron-mtnxbrvi/download' --output '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md.part' && mv '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md.part' '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Environment declared by the author: Linux, macOS
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md' && test -s '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/cron' && cp -R '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi' '.claude/skills/cron'Cursor
test -f '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md' && test -s '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/cron' && cp -R '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi' '.cursor/skills/cron'Codex
test -f '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md' && test -s '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/cron' && cp -R '.skill-downloads/schedule-tasks-with-cron-mtnxbrvi' '.agents/skills/cron'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/schedule-tasks-with-cron-mtnxbrvi'openskills read 'schedule-tasks-with-cron-mtnxbrvi'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/schedule-tasks-with-cron-mtnxbrvi/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
Configure a Chat Channel with SecretRefs
DevOps
Set up chat channels using non-interactive commands, with secrets only as SecretRefs. Covers gather, mutate, repair, and prove steps for reliable delivery.
Investigate ClickHouse CI Failures
DevOps
Investigate a ClickHouse CI failure end-to-end from a PR or S3 report URL. Fetches failed tests, classifies flaky vs real regression, and checks for existing issues/fixes.
Ansible PR Review
DevOps
Reviews an Ansible PR following the project's standardized process, including changelog checks, test coverage validation, and feedback tracking.