Skip to content
Back to skills

Cron Job

CSecurity

Set up a reliable scheduled job via cron or a systemd timer, with logging and failure visibility

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 3, 2026
ai-agentsgoshell

Security analysis

C60/100
  • highCreates or modifies cron jobs for persistent execution
  • criticalModifies startup scripts or system services for persistence

Pro shows the line behind each finding and how to fix it

Scanned September 3, 2026

npx -y skills add black141312/ada --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: C — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-cron-job/badge)](https://www.skillsdirectory.com/skills/black141312-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: Set up a reliable scheduled job via cron or a systemd timer, with logging and failure visibility
category: shell
---

# Cron Job

Use this when scheduling recurring work — backups, syncs, cleanups, health checks — via cron or systemd timers.

1. Choose the mechanism: classic `cron`/`crontab -e` for simple periodic jobs, or a systemd `.timer` + `.service` pair when you need dependencies, resource limits, or `journalctl` logging.
2. Have cron call a single self-contained script (with `set -euo pipefail`), not a long inline command — cron's minimal env and lack of quoting bites inline one-liners.
3. Use absolute paths for the binary, inputs, and outputs; cron runs with a bare `PATH` and no shell profile, so never assume `~`, aliases, or sourced env are present.
4. Redirect output to a log (`>> /var/log/job.log 2>&1`) or rely on the journal for timers; a silent cron job that fails is invisible.
5. Pick the schedule explicitly (`m h dom mon dow` for cron, `OnCalendar=` for timers) and add jitter/`RandomizedDelaySec` if many hosts fire at once.
6. Test by running the script manually first, then trigger the unit (`systemctl start job.service`) or wait one cycle and check the log before walking away.

## Rules
- Guard against overlapping runs with `flock -n /tmp/job.lock` (cron) or systemd's default single-instance behavior.
- Make the job idempotent so a missed or doubled run doesn't corrupt state.
- Set `MAILTO=` or pipe failures to an alert; never let errors vanish into `/dev/null`.
- Enable the timer to survive reboots: `systemctl enable --now job.timer`, and use `Persistent=true` to catch missed runs while powered off.
- Pin the timezone you expect (`CRON_TZ=` / `OnCalendar` with explicit TZ) — DST shifts silently break wall-clock schedules.

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…