Run tasks once without leaving cron garbage behind
Cron & Task Scheduling (Cron/Systemd Timers/At)
Run tasks once without leaving cron garbage behind
🧩 The Challenge
Dealing with a one-off task that you need to run later is a pain when you have to edit crontab, save it, wait for it to fire, and then remember to delete the line before it runs again next week. I’ve left far too many test scripts firing on production boxes because I forgot to clean up my crontab entries.
💡 The Fix
Use the at command instead of cluttering up your crontab for jobs that should only execute a single time. It handles the scheduling and cleanup for you automatically.
echo "/usr/local/bin/sync-backups.sh" | at 03:00 tomorrow
⚙️ Why It Works
This utility schedules the task into a queue and purges it from the system the second the job completes. You never have to go back and scrub your configuration files to stop the job from repeating.
🚀 Pro-Tip: Check your pending queue with atq and cancel anything you regret scheduling by using atrm followed by the job ID.
Linux Tips & Tricks | © ngelinux.com | 9/10/2026
