How to run a Kubernetes CronJob immediately (kubectl trigger)
Codemia Knowledge Hub ·
Create a one-off Job from the CronJob's template with kubectl create job --from=cronjob/<name> <job-name>. It runs the same pod spec right away and leaves the CronJob's schedule alone.
Create a Job from the CronJob
This copies the jobTemplate of the CronJob nightly-report into a normal Job named nightly-report-manual. The CronJob keeps its schedule and still runs later; the manual run is just an extra execution.
For a unique name, add a timestamp:
This is the cleanest method for testing, emergency runs and debugging.
Confirm the job actually started
Inspect it like any other job:
These show whether the pod was created, whether it is failing on image pulls or environment setup, and whether the container completed. Check the pod logs too: a job can exist while its pod crash-loops or fails immediately.
Why not edit the schedule instead
Temporarily setting the schedule to every minute, waiting, and changing it back works, but it is noisy, easy to forget, and can trigger several runs instead of one. A one-off Job:
- leaves the original schedule untouched
- avoids repeated accidental runs from a temporary cron expression
- has its own job name and logs
In most operational environments, that keeps troubleshooting much cleaner, and nobody has to remember to revert a modified CronJob.
Changing parameters for a manual run
If you need a small variation for debugging, such as a different environment variable or argument, export the CronJob:
Copy its jobTemplate.spec into a standalone Job manifest and adjust it:
Apply it:
This takes more work than kubectl create job --from=cronjob, but it gives you a controlled variant of the scheduled workload.
Manual jobs ignore concurrencyPolicy
The CronJob's concurrencyPolicy only controls what the CronJob controller does with scheduled runs. It does not stop you from creating an extra manual Job, so you can start one while a scheduled run is still active. Be careful with backups, billing, data imports, and anything else where duplicate execution hurts.
Also, --from=cronjob/... copies the current template. If the CronJob spec is wrong, the manual job reproduces the same mistake.
Cleaning up manual jobs
If your cluster does not already use TTL cleanup, delete manual jobs after testing. Leaving many old manual jobs around makes later troubleshooting harder:
Related reading
- How to run shell script using CronJobs in Kubernetes?
- How to scale k8s pods according to rabbitmq queue message rate?
- How to scale knative service based on custom metrics?
- how to scale kubernetes daemonset to 0?
- How to run Nginx within a Docker container without halting?
- How to run shell script on host from docker container?
- How to schedule pods restart
- How to scrape metrics-server to prometheus outside kubernetes cluster
System design interview problems on this topic
- Design a Container Orchestration System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design a Task Scheduler: solution and walkthrough
- Design a GPU Cluster Scheduler for ML Training: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.