Cron is a Linux scheduler that runs commands and scripts on a set schedule: making backups, clearing cache, sending reports. You can create a job in two ways: add a line to crontab via the terminal or fill out a form in the scheduler section of your control panel. In this article, we'll cover both approaches.

What Cron Is and How to Read a Schedule

Cron is a service (daemon) that checks its job list once a minute and runs whatever is due. A single job is called a cron job, and the file holding a user's list of jobs is called a crontab.

Scheme of crone

A few common schedules:

Schedule

When it runs

What it's good for

*/5 * * * *

every 5 minutes

checking a task queue

0 */2 * * *

every 2 hours, on the hour

data synchronization

0 3 * * *

daily at 3:00 AM

backup

30 6 * * 1

Mondays at 6:30 AM

weekly report

0 9 * * 1-5

weekdays at 9:00 AM

sending notifications

0 0 1 * *

the 1st of every month at midnight

log rotation

The entry * * * * * runs a command every minute. That's handy for testing, but running something this often on a permanent basis adds unnecessary load to the server, and shared hosting may not even allow it. If your script doesn't need minute-level precision, use a longer interval.

Before You Start: What to Prepare

Most "broken" jobs don't fail because of the schedule itself — they fail on small details. Before adding a job, run through this checklist:

  • Absolute paths. Cron has no idea which folder you usually run your script from. Use /usr/bin/php instead of just php, and the full path to the script file itself. You can find the interpreter's path with the which php command.

  • Execute permissions. A shell script needs the execute flag (chmod +x script.sh). A PHP file run through php works without it, but the user still needs read access.

  • A manual test run. Run the command in the terminal exactly as you plan to put it in cron. If it doesn't work manually, it definitely won't work on a schedule.

  • Output handling. Redirect it to a log (>> /path/to/log.txt 2>&1) or to /dev/null if you don't need the result. Otherwise cron will try to email the output to the user.

  • Time zone. The job runs according to the server's time, not yours. Check with the date command before scheduling a "nightly" backup.

Creating a Job via Crontab in the Terminal

This method requires SSH access to the server. If you haven't connected over SSH yet, start with the article What Is SSH.

  1. Connect to the server over SSH as the user the job should run under.

  2. Run crontab -e. On the first run, the system may ask you to pick an editor: nano is the easiest choice for beginners.

  3. Add a line at the end of the file. Example: clearing out temporary PHP script data every day at 3:00 AM, with output written to a log:

0 3 * * * /usr/bin/php /home/user/site/scripts/cleanup.php >> /home/user/logs/cleanup.log 2>&1
  1. Save the file and close the editor (in nano: Ctrl+O, Enter, Ctrl+X). Cron picks up the changes automatically — no need to restart the service.

  2. Check the list: crontab -l.

Another example — archiving the site directory every night at 2:15 AM:

15 2 * * * tar -czf /home/user/backups/site-$(date +\%F).tar.gz /home/user/site

Note the \%: in crontab the percent sign has a special meaning, so it must be escaped with a backslash inside the command. This is one of the most common sources of "mysterious" errors.

Where to check the results. On Debian and Ubuntu, cron runs are logged to the system log: grep CRON /var/log/syslog. On AlmaLinux, Rocky, and other RHEL-based systems, check /var/log/cron. The log will confirm that the job ran, but not how it ended — that's what the log file we set up in the command itself is for.

User and system crontabs are different things. The crontab -e command edits a specific user's file, and the line doesn't include a username. The system file /etc/crontab and the /etc/cron.d/ directory are edited as root, and there a sixth field is added between the schedule and the command — the user the job runs as. For your first jobs, a user crontab is enough.

Full crontab and SSH access is usually available on a VPS; on shared hosting, what you can do depends on your plan. More on that at the end of the article.

How to Create a Cron Job in Control Panels

Every panel works the same way: you specify a schedule and a command, and the panel turns it into a crontab line behind the scenes. Only the section names and the set of fields differ. Below is the path to the form, what to fill in, and how to verify the result. If you're not familiar with a given panel, check out the overviews first: Plesk, HestiaCP, cPanel.

cPanel

  1. On the home page, open the Advanced section and select Cron Jobs.

  2. Optionally, enter an address in the Cron Email field: job output will be sent there. If you don't need emails, it's better to redirect output straight to /dev/null inside the command itself.

  3. In the Add New Cron Job section, pick a preset from the Common Settings list (for example, once an hour or once a day), or fill in the Minute, Hour, Day, Month, and Weekday fields manually.

  4. In the Command field, paste the command with absolute paths, for example /usr/local/bin/php /home/user/public_html/cron.php. Check the PHP path on your specific server beforehand.

  5. Click Add New Cron Job. The job will show up in the Current Cron Jobs list, where you can edit or delete it.

Plesk

In Plesk, jobs are tied to a subscription and a system user, so the first thing to figure out is which user the script will run as.

  1. Open Websites & Domains, find the domain you need, and go to Scheduled Tasks.

  2. Click Add Task and pick a type: Run a command, Run a PHP script, or Fetch a URL. For a script on your site, the second option is more convenient — Plesk fills in the PHP path for you.

  3. Enter the path to the script or the command. In the Run section, you can pick a preset period (hourly, daily, weekly) or choose "Cron style" and enter the five schedule fields manually.

  4. Check which system user the job runs as, and enable result notifications if needed.

  5. Save the task with the OK button. To test it without waiting, there's a manual run button in the list.

We've covered regular backups in Plesk separately: How to Create a Website Backup in Plesk. There, the schedule is set inside Backup Manager; here we're covering the universal cron mechanism.

Планировщик в панели управления Plesk

Заполняем поля планировщика Plesk

HestiaCP

In HestiaCP, jobs live in a separate tab in the top menu, and the form itself is compact.

  1. Log in as the user you need and open the CRON tab.

  2. Click the add-job button (Add Cron Job).

  3. In the Command field, enter the command, then set the minute, hour, day of month, month, and day of week below. Quick presets are available nearby for common cases (every minute, hourly, daily, etc.).

  4. Click Save. The new entry will appear in the list, and you can pause any job without deleting it.

Commands in HestiaCP run as the panel user, so paths to the site will look like /home/username/web/domain/public_html/. Check the exact path using the file manager.

Раздел Cron в Hestia

Кнопка Cron Job

Расписание Cron

Common Mistakes and How to Verify a Job Is Working

Symptom

Likely cause

What to do

Job doesn't run at all

typo in the schedule or wrong format

check the five fields with crontab -l or the panel form

Log shows "command not found"

using php instead of /usr/bin/php

use absolute paths, find them with which

"Permission denied"

no permissions on the script or directory

grant permissions with chmod +x and check file ownership

Works manually but not via cron

cron has a different, limited PATH environment

set full paths and variables inside the script

Job runs at the wrong time

server time zone differs from yours

check date and recalculate the schedule

Last line is ignored

no trailing newline at the end of crontab

add a blank line after the last job

Server slows down

schedule too frequent or script too heavy

increase the interval, spread jobs out over time

To confirm everything is working, go through three steps: find the run in the system log (if you have access to it), open the job's own log, and check the script's actual result (a file, a database record, an email).

Cron on Shared Hosting vs. VPS: What's the Difference

On shared hosting, cron is usually available through the panel, with limits set by the hosting provider: this might be a minimum interval between runs, a cap on the number of jobs, or restrictions on script execution time. For a WordPress site, small scripts, and regular backups, this is generally enough.

On a VPS, you manage the server yourself: SSH access and any user's crontab are available, you can set up system-level jobs in /etc/cron.d/, write your own scripts, and tune the schedule to match the load. The responsibility for configuration is on you too. If you're just getting started, begin with shared hosting; if you need full control over the scheduler, check out VPS plans and shared hosting plans.

Conclusion

The rule of thumb is simple: for routine site tasks, create the cron job in the panel; if you need full control, use crontab in the terminal. Either way, the process is the same: test the command manually, use absolute paths, set up logging, and do a test run. If you're already hitting the scheduler's limits on your hosting plan, compare your options on the VPS plans page.

FAQ

How do I see the list of cron jobs?

In the terminal, run crontab -l for the current user, or sudo crontab -u username -l for another one. In the control panel, the list is on the same page where you created the job.

How do I run a PHP script via cron?

Specify the full path to PHP and to the script, for example /usr/bin/php /home/user/site/cron.php. In cPanel and Plesk, it's best to confirm the interpreter path in the panel, since the server may have several PHP versions installed.

How do I disable or delete a job?

In crontab -e, delete the line or comment it out with a #. In the panel, use the delete or pause button, if available.

Why isn't my job running?

The most common causes are a relative path, insufficient permissions, an incorrect schedule, or a different time zone. Test the command manually, then check the job's log and the system log.

Which is better: a cron job from the panel or crontab in the terminal?

For simple site tasks, the panel is more convenient: no SSH required, and the fields guide you through the format. If you need system-level jobs, multiple users, or fine-grained configuration, the terminal and a VPS are the better choice.