Schedule a One-Time Cron Job — Run Once and Never Again
Table of Contents
Cron is designed for recurring jobs — but there are clean ways to run a one-time task at a specific future time. The right tool depends on your platform: the at command for Linux one-shots, a date-specific cron expression that effectively runs once per year, or platform-native one-time mechanisms in Kubernetes, AWS, and GitHub Actions.
Build any date-specific expression with our free cron generator. This guide covers all the patterns and when each one is appropriate.
The at Command — The Real Tool for One-Time Linux Jobs
For Linux one-time scheduling, the at command is the correct tool. It's designed specifically for this:
# Run a command at a specific time (install at if needed: apt install at)
echo "/path/to/script.sh" | at 09:30 tomorrow
echo "/path/to/script.sh" | at 09:30 04/15/2026
echo "/path/to/script.sh" | at now + 2 hours
echo "/path/to/script.sh" | at noon next monday
# List scheduled at jobs
atq
# Remove a job (use job number from atq)
atrm 3
at jobs run once and are automatically removed after execution. No cleanup required, no self-deletion logic needed. The atd daemon must be running (systemctl status atd).
If at isn't available on your system (some minimal cloud images don't include it), install with apt install at (Debian/Ubuntu) or yum install at (RHEL/CentOS).
Date-Specific Cron Expression That Runs Once Per Year
Standard 5-field cron has no year field — an expression targeting April 15 at 9:30 AM will run every April 15. For a "practically once" schedule (you'll have removed it before next year), this works:
30 9 15 4 * # 9:30 AM on April 15 — every year, but you'll remove it
Build the exact date in the cron generator: set month to April, day-of-month to 15, hour to 9, minute to 30. Verify with the visualizer — it will show the next occurrence as April 15.
Remove it after it runs. Set a calendar reminder for April 16 to clean up the crontab entry. Alternatively, use the self-deleting pattern below.
When this is appropriate: Quick one-off tasks where at isn't available and you know you'll clean up the crontab. Not appropriate for automated deployments where the crontab file is managed by IaC.
Self-Deleting Cron Wrapper
A cron job that removes itself from the crontab after running — no manual cleanup required:
#!/bin/bash
# one-time-job.sh
# Run your actual task
/path/to/actual-task.sh
# Remove this job from crontab
crontab -l | grep -v 'one-time-job.sh' | crontab -
Add to crontab targeting your desired run time:
30 9 15 4 * /path/to/one-time-job.sh
After the job runs, it removes itself. The crontab entry is gone — no future recurrence, no manual cleanup.
Warning: If the script errors before reaching the self-deletion line, it stays in the crontab and will run again next year. Add set -e at the top of the script so it exits immediately on any error — but be aware this means the self-deletion line won't run on failure either. Structure critical one-time jobs as run-task || true; self-delete if you always want cleanup regardless of success.
One-Time Jobs on Kubernetes, AWS, and GitHub Actions
Kubernetes — use Job, not CronJob:
apiVersion: batch/v1
kind: Job
metadata:
name: one-time-migration
spec:
template:
spec:
containers:
- name: worker
image: my-image:latest
restartPolicy: Never
A Kubernetes Job runs once to completion and stops. CronJob is for recurring tasks — use Job for one-time work like database migrations, data backups, or environment setup.
AWS EventBridge Scheduler — native one-time schedule: Unlike classic EventBridge Rules, EventBridge Scheduler supports one-time schedules directly. In the console, choose "One-time schedule" instead of "Recurring" and set the exact date and time. No cron expression needed.
GitHub Actions — workflow_dispatch: For one-time manual triggers, use workflow_dispatch instead of schedule. This lets you trigger the workflow from the GitHub UI or via the API at any time without writing a schedule expression.
AWS Lambda — schedule expression with date: Classic EventBridge rules can use a date-specific cron: cron(30 9 15 4 ? 2026) — the year field makes this truly run once (in 2026 only). Delete the rule after it fires.
Try It Free — No Signup Required
Runs 100% in your browser. No account, no install, no limits.
Open Free Cron GeneratorFrequently Asked Questions
How do I run a cron job only once at a specific time?
The cleanest option on Linux is the "at" command: "echo '/path/to/script.sh' | at 09:30 04/15/2026". It runs once and removes itself automatically. If "at" isn't available, use a date-specific cron expression ("30 9 15 4 *") and remember to remove it after it runs, or use the self-deleting wrapper pattern.
Can cron expressions target a specific year?
Standard 5-field cron has no year field — an expression targeting a specific date will repeat every year. AWS EventBridge cron (6-field) adds a year field: "cron(30 9 15 4 ? 2026)" runs only once in 2026. Quartz/Spring Boot also supports an optional year field in its 7-field format.
What is the difference between a cron job and an at job?
Cron is for recurring scheduled tasks — "run this every day at 9 AM." The at command is for one-time future execution — "run this once at 9 AM tomorrow." Cron jobs persist until you remove them. at jobs run once and are automatically cleaned up. For genuinely one-time tasks, at is the right Unix tool; cron is the wrong choice that developers reach for because it's more familiar.

