Couldn't find what you are looking for?

Knowledgebase Banner - WordPress Web Hosting

How do I run my PHP script as a scheduled (cron) task?

Scheduling tasks allows you to automate various scripts to be run from your hosting package.

Running PHP files on your site is a commonly requested task.

This is absolutely possible, and easy, providing you know how it's done.

The first thing you need to know is how command lines are structured.

They are structured as follows:

/path/to/interpreter /path/to/file_to_be_interpreted Argument_to_be_passed_to_file_to_be_interpreted

In this example for a PHP file, you'd need something like this:

/usr/bin/php /home/sites/ task=tidy owner=1

The above file specifies that you want the PHP interpreter to interpret the cron.php file in the webspace of, giving it the arguments task=tidy and owner=1.

This is the equivalent of loading the following URL from a web browser:

Specifying the PHP version

You can specify what version of PHP you want to use to run your PHP script in your command.

We have multiple versions of PHP installed on our servers (versions 4, 5.2, 5.3, 5.4 and 5.5), all of which can be used to run a PHP script as a scheduled task.

To specify a specific one, you just need to amend the path to the interpreter in your command.

The /usr/bin/php path refers to a symbolic link, which refers to the default version of PHP on our servers (version 5.3).

Here are the paths to each version of the interpreter should you wish to specify:

  • Default PHP version: /usr/bin/php
  • PHP 4: /usr/bin/php4
  • PHP 5.2: /usr/bin/php5
  • PHP 5.3: /usr/bin/php53
  • PHP 5.4: /usr/bin/php54
  • PHP 5.5: /usr/bin/php55


  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

File Manager session expiry errors

In order to keep your files secure against various threats, File Manager...

What Java Support is in place?

We support Javascript and Java Applets as standard as they are client-side. We do...

How do I run scheduled tasks (cron jobs) on my account, and how frequently can I run them?

Scheduled tasks (also known as cron jobs) can be set up though eXtend. This feature allows a...

I would like to be able to see a breakdown of countries in my Webalizer statistics.

It is possible to get a breakdown of countries in your Webalizer statistics but it is...

Using PHP5 makes all my products disappear in OSCommerce

We have updated our version of php so the default used is PHP5 rather than PHP4. This...