Practical crontab guide covering schedule syntax, system and per-user config files, safe script templates, logging, and troubleshooting.
- skills.sh installs
- 1.3K
- GitHub stars
- 60
- last updated
- Aug 21, 2026
What it does
- Covers crontab management with
crontab -e,-l,-r, and-u, plus schedule syntax and special strings like@dailyand@reboot - Includes config locations for user crontabs,
/etc/crontab,/etc/cron.d, and the hourly, daily, weekly, and monthly directories - Provides a script template with a lock file to block duplicate runs and
flockfor single-instance jobs - Designed for server administrators scheduling backups, log rotation, and health checks on Debian or RHEL systems
Install
$ npx -y skills add chaterm/terminal-skills --skill cron -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
定时任务管理
概述
Cron 定时任务配置、日志监控、故障排查等技能。
Crontab 基础
管理命令
# 编辑当前用户的 crontab
crontab -e
# 查看当前用户的 crontab
crontab -l
# 删除当前用户的 crontab
crontab -r
# 管理其他用户的 crontab(需要 root)
crontab -u username -e
crontab -u username -l
时间格式
┌───────────── 分钟 (0-59)
│ ┌───────────── 小时 (0-23)
│ │ ┌───────────── 日 (1-31)
│ │ │ ┌───────────── 月 (1-12)
│ │ │ │ ┌───────────── 星期 (0-7, 0和7都是周日)
│ │ │ │ │
* * * * * command
特殊字符
* # 任意值
, # 列表 (1,3,5)
- # 范围 (1-5)
/ # 步长 (*/5 每5分钟)
# 示例
0 * * * * # 每小时整点
*/15 * * * * # 每15分钟
0 9-17 * * * # 9点到17点每小时
0 0 * * 1-5 # 工作日零点
0 0 1,15 * * # 每月1号和15号零点
特殊时间字符串
@reboot # 系统启动时
@yearly # 每年 (0 0 1 1 *)
@monthly # 每月 (0 0 1 * *)
@weekly # 每周 (0 0 * * 0)
@daily # 每天 (0 0 * * *)
@hourly # 每小时 (0 * * * *)
配置文件
用户 crontab
# 位置
/var/spool/cron/crontabs/username # Debian/Ubuntu
/var/spool/cron/username # CentOS/RHEL
# 格式
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin
MAILTO=admin@example.com
# 任务
0 2 * * * /usr/local/bin/backup.sh
Details
- Repository
- github.com/chaterm/terminal-skills
- Categories
- CLI & Terminal, DevOps & Cloud
More from chaterm/terminal-skills
All 5Similar to Cron
More CLI & Terminal
systemdchaterm/terminal-skills262 installsSystemd service management guide covering unit files, service types, sandboxing, journal logs, and timers.
remind-mesundial-org/awesome-openclaw-skills888 installsNatural-language reminders that schedule one-time or recurring cron jobs and log each to markdown.
linux-shell-scriptingsickn33/agentic-awesome-skills181 installsProduction-ready bash templates for Linux admin tasks: backups, monitoring, users, logs, and automation.
linux-administrationbagelhole/devops-security-agent-skills867 installsPractical Linux server administration reference covering packages, filesystems, processes, cron, logs, and networking on Debian/Ubuntu and RHEL/CentOS.
schedulerwarpdotdev/oz-skills295 installsOn-device reminder and local task scheduler that asks for delivery method and timezone before creating anything.
