Migrating production infrastructure? Get up to ₹10,000 in migration credits. Apply now
voroaBlog
Background Workers

What Is a Cron Job? Syntax, Examples and Where to Run It

· · 6 min read

What is a cron job, the syntax, examples and where to run it

What is a cron job? It is a command that a computer runs automatically on a schedule: every night at 2 am, every 15 minutes, every Monday morning. The name comes from cron, the Unix program that has done this since the 1970s.

This guide explains how cron works, how to read and write a schedule, and the few mistakes that cause most cron problems. It ends with where to run cron jobs when you do not manage your own server.

On this page

Advertisement

How cron works

On a Linux server, a small program called the cron daemon wakes up every minute. It reads a list of jobs, checks which ones are due at that minute, and runs them.

Each job is one line: a schedule followed by a command. The list is called a crontab (“cron table”). Each user on the server has their own.

# minute hour day-of-month month day-of-week  command
0 2 * * * /home/app/backup.sh

That line runs backup.sh at 2:00 am every day.

The five fields

Diagram: the five fields of a cron expression, minute, hour, day of month, month and day of week, with allowed values and the example 30 9 * * 1-5 meaning 9:30 am Monday to Friday

Field Allowed values Special characters
Minute 0-59 * any, , list, - range, / step
Hour 0-23 same
Day of month 1-31 same
Month 1-12 or JAN-DEC same
Day of week 0-7 or SUN-SAT (0 and 7 are Sunday) same

Read it left to right. 30 9 * * 1-5 means minute 30, hour 9, any day of the month, any month, Monday to Friday: 9:30 am on weekdays.

One quirk: if you set both day-of-month and day-of-week, standard cron runs when either matches. 0 9 1 * 1 runs on the 1st of every month and every Monday.

Examples you can copy

What you want Expression
Every minute * * * * *
Every 5 minutes */5 * * * *
Every hour, on the hour 0 * * * *
Every day at midnight 0 0 * * *
Every day at 2:30 am 30 2 * * *
Weekdays at 9 am 0 9 * * 1-5
Every Sunday at 6 pm 0 18 * * 0
First day of every month 0 0 1 * *
Every 15 minutes, 9 am to 5 pm on weekdays */15 9-16 * * 1-5

Some step values do not divide an hour evenly and leave short gaps. Our guide to cron every 5 minutes shows which ones and why.

Working with crontab

On a Linux server:

bash
crontab -e      # edit your crontab (opens an editor)
crontab -l      # list your jobs
crontab -r      # remove ALL your jobs - careful

A safe line looks like this:

*/15 * * * * cd /home/app && /usr/bin/node scripts/sync.js >> /var/log/sync.log 2>&1

It uses full paths, changes to the right folder, and sends both output and errors to a log file so you can see what happened.

Five mistakes that break cron jobs

1. The wrong timezone. Cron uses the server’s timezone, which is usually UTC on cloud servers. 0 9 * * * then runs at 2:30 pm in India. To run at 9 am IST on a UTC server, write 30 3 * * *.

2. A missing PATH. Cron runs with a very short PATH, so node or python may not be found. Use full paths such as /usr/bin/node.

3. No output anywhere. By default cron’s output is mailed or lost. Redirect it to a log file, as above, or nothing tells you the job failed.

4. Overlapping runs. Cron starts each run on time even if the last one is still going. On Linux, flock -n skips a run while the previous one holds a lock.

5. Duplicate runs. If the same crontab, or the same in-app scheduler, runs on two servers, every job runs twice. We measured exactly that with node-cron in Node.js: two instances, 40 runs instead of 20.

Cron job or background worker?

Both run code with no web page. The difference is whether the program is meant to stop.

Your program Use
Runs a report, sends a digest or cleans up, then exits Cron job
Waits for jobs on a queue and processes them as they arrive Background worker
Holds a websocket or a long-lived connection Background worker

If your script ends on its own, it is a cron job. If it should still be running tomorrow, it is a worker.

Where to run cron jobs today

Option Good for Watch out for
Your own Linux server Full control, any schedule You maintain the server; timezone is the server’s
A scheduler inside your app (node-cron, APScheduler, Celery beat) Jobs tied to app code Runs twice if the app runs twice
A platform’s cron feature No server to manage Minimum intervals, UTC by default, best-effort timing

Hosting platforms differ a lot here. GitHub Actions runs schedules at most every 5 minutes, Heroku Scheduler every 10 minutes, and most use UTC. The GitHub Actions schedule docs are a typical example.

Cron jobs on Voroa

On Voroa you can create a Cron Job from a GitHub repository: give it a command and a schedule, from a preset such as Every hour or a cron expression. Schedules run in India Standard Time, so 0 9 * * * means 9:00 am IST.

Voroa builds the repository into a small service that stays running and runs your command inside it. A slow run can overlap the next, so keep jobs safe to run twice. Runs are also skipped while the service is stopped, for example after a free workspace uses its monthly free hours, so do not rely on every run firing.

Details are in scheduling a task on Voroa, and worker or cron job helps you pick. Long-running processes go on the background workers page.

FAQ

What is a cron job in simple words? A command that runs automatically on a schedule, such as every night or every 15 minutes.

What does * * * * * mean? Every minute of every hour of every day. Each star means “any value” for that field.

What is the difference between cron and crontab? Cron is the program that runs scheduled jobs. A crontab is the file listing those jobs.

What timezone does a cron job use? The server’s timezone, usually UTC in the cloud. Check it before you pick an hour.

Can a cron job run every second? Not with standard cron, whose smallest unit is one minute. Some in-app schedulers accept a seconds field.

How do I see if my cron job ran? Send its output to a log file, or have the job record its result somewhere you can check, such as a row in a database.

Updated 7 November 2026. Found something out of date? Write to support@getvoroa.com.

Advertisement