Shared hosting

How to run a PHP script on a schedule (cron)

2013-05-04

The scheduler (cron) runs a PHP script, a site URL or a command automatically on a schedule. To create a job:

  1. Open "Main" -> "Scheduler".
  2. Click "Create job".
  3. Choose the command type:

    • "URL" - open a site address, for example https://example.com/cron.php?key=123;
    • "PHP script" - run a PHP file: choose the "PHP version" (the same as the site's), the "File" and, if needed, "Arguments";
    • "Custom command" - any command.

    The "Command that will run" field shows the final command.

  4. Set the "Schedule": a preset ("Every 5 minutes", "Every hour", "Every day (00:00)" etc.) or "Advanced" mode with cron fields.
  5. Optionally add a "Description" and save.

How to run a PHP script on a schedule (cron)

To test the job, click "Run now": it runs immediately.

Important

  • A line like php /path/file.php?param=1 will not open a URL with parameters. To call a site address, use the "URL" type.
  • A bare php in a command is the account's default version, not the site's version. Choose the version explicitly.

How to get job output by email

  1. In the "Scheduler" section, click "Settings".
  2. In "Job output notifications", choose where to send job output and errors: to the account email, to another address, or nowhere.

The same place has "PATH" - the directories where cron looks for commands. Leave it empty to use the default value.