system-cron-setup

Configure system-level crontab entries in /etc/cron.d/ for scheduled tasks and service monitoring.

Updated Jul 3, 2026
One-click install
npx skills add https://github.com/CHENHUI-X/toolbox --skill system-cron-setup-chenhui-x
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: system-cron-setup
Source: https://github.com/CHENHUI-X/toolbox/tree/main/custom-skills/devops/system-cron-setup
Command: npx skills add https://github.com/CHENHUI-X/toolbox --skill system-cron-setup-chenhui-x

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Scheduled tasks that must survive a gateway or application crash cannot rely on an in-process cron scheduler. This Skill sets up system-level crontab entries under /etc/cron.d/ so watchdogs, health checks, and maintenance scripts keep running independently of any single process. ## Core Features & Use Cases - System Crontab Management: Create, migrate, and maintain cron entries in /etc/cron.d/ with correct 6-field format, permissions, and timezone handling (Asia/Shanghai). - Health Check & Notification Scripts: Deploy silent-when-healthy watchdog scripts that restart failed systemd services and send Telegram Bot API alerts. - Troubleshooting Rogue Cron Jobs: Investigate unexpected service restarts by checking both /etc/cron.d/ and user crontabs, plus cron journal logs. - Use Case: A gateway process keeps dying at night. Use this Skill to create a system cron watchdog that checks the service every 5 minutes, restarts it on failure, and sends a Telegram notification with the new PID. ## Quick Start Ask the agent to create a system crontab entry that runs a health check script every 5 minutes and notifies you on Telegram if the service is down.

Frequently Asked Questions about system-cron-setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a cron job in /etc/cron.d/ on Linux?

Write a file to /etc/cron.d/<task-name> using the 6-field format: schedule, user, then command, for example '*/5 * * * * root /path/to/script.sh'. Set permissions to 644 with root ownership using chmod and chown.

What is the difference between /etc/cron.d/ and crontab -e?

Files in /etc/cron.d/ are system crontabs requiring a username field, while crontab -e edits the per-user crontab stored in /var/spool/cron/crontabs/. VPS setup scripts often use the user crontab, so check both when auditing scheduled tasks.

How do I send Telegram notifications from a cron script?

Call the Telegram Bot API directly with curl from the script, reading the bot token and chat ID from your .env file at runtime. This works even when the monitored service is down and cannot deliver messages itself.

Why does my cron job run at the wrong time?

Cron uses the system timezone, not UTC. Verify with 'timedatectl | grep "Time zone"' before writing entries, and write the schedule directly in the system timezone instead of converting from UTC mentally.

How do I find what caused an unexpected service restart?

Grep all cron locations for restart commands: 'grep -r "restart.*<service>" /etc/cron* /var/spool/cron/'. Then check 'journalctl -u cron' around the restart time to see the exact command that ran, and inspect both system and user crontabs.

Why does systemctl restart fail after a service was killed?

A service killed by SIGKILL enters a failed state that plain restart may not clear. Run 'systemctl reset-failed <service>' first to clear the failed state, then 'systemctl restart <service>' to start it fresh.