Cron & Task Scheduling (Cron/Systemd Timers/At)
No More One-Off Cron Entries for Single Tasks
đź§© The Challenge
Look, we’ve all been there. You need a command to run *just once*, maybe at 2 AM, maybe next Tuesday. So you open your crontab, add the entry, and then curse yourself when you forget to remove it a week later. Or maybe you need to kick off a script after you’ve logged out and `nohup` feels clunky for a precise time.
đź’ˇ The Fix
But there’s a simple, often-forgotten command for exactly this: `at`. It lets you schedule a single task to run at a specific future time, and it just handles it, no permanent cron entry needed. It’s perfect for those “run it and forget it” situations.
at 02:30 tomorrow <<'EOF'
/usr/local/bin/do_some_maintenance.sh
/usr/bin/rsync -av /var/log/myapp/errors.log backup-server:/data/logs/
/usr/bin/systemctl restart myapp.service
EOF
# Need to see what's pending? `atq`
# Messed up and need to delete job 17? `atrm 17`
# For a delay: at now + 30 minutes
# For a specific date: at 10:00 03/25/24
⚙️ Why It Works
This little utility pushes your commands into a spool directory, and the `atd` daemon running in the background then executes them when the time comes. It uses the environment variables that were active when you *submitted* the job, which can save you headaches with paths or specific settings.
🚀 Pro-Tip: Seriously, if `at` isn’t working, check `systemctl status atd`. Nobody tells you to do that upfront.
Linux Tips & Tricks | © ngelinux.com | 10/22/2026
