How to Create a Cron Job (Scheduled Task)

A cron job runs a command or PHP file automatically at set intervals. For example, it can take a backup every night, process an e-mail queue every 15 minutes or run WordPress scheduled tasks.

Creating a cron job in Plesk

  1. Go to Websites & Domains > Scheduled Tasks.
  2. Click Add Task.
  3. Choose the task type: Run a PHP script, Fetch a URL or Run a command.
  4. Enter the file path or address, choose how often it runs and click OK.

Creating a cron job in cPanel

  1. Go to Advanced > Cron Jobs.
  2. Choose the frequency from Common Settings (e.g. Once Per Hour).
  3. Type the command in the Command field and click Add New Cron Job.

Example commands

Running a PHP file:

/usr/local/bin/php /home/username/public_html/cron.php

Calling an address:

wget -q -O /dev/null https://yourdomain.com/cron.php

The full PHP path may differ depending on the server and PHP version. In Plesk, the "Run a PHP script" option fills in the path for you.

How to read the time expression

The five fields mean minute, hour, day of month, month, day of week, in that order.

  • */15 * * * * : every 15 minutes
  • 0 3 * * * : every day at 03:00
  • 0 9 * * 1 : every Monday at 09:00

Tip for WordPress

WordPress's own scheduler (wp-cron) runs on every page load and can slow your site down. Add the line define('DISABLE_WP_CRON', true); to wp-config.php and create a cron job on the server that calls wp-cron.php every 15 minutes. For details, see our article on wp-cron.php.

Please note

Running tasks more often than needed (such as every minute) can use up your account's resource limits.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

What is Hosting?

Virtual hosting is a type of hosting in which a web server is divided into sections, each of...

What is a Reseller?

The word “reseller” refers to a person or company that buys a product or service directly from...

What is DNS?

Every object on the Internet, every server and endpoint that interacts with others, needs an...

What is a Domain Name? Where Can I Get One?

A domain name is the name and address of your website on the Internet. Without this address, your...

Which Operating System Should I Choose for My Hosting?

The answer depends on the software your website needs. If you want to use ASP or .NET pages...