Skip to the guide

Scheduled tasks on a website

A scheduled task runs one of your website’s PHP files on a timetable: Laravel’s scheduler every minute, a nightly tidy-up, a weekly report. It is a cron job, with the five cron fields you already know. This page sets one up, gives the schedule syntax with worked examples, and lists every limit and every refusal.

Scheduled tasks for a website in Dashmox, with what each one runs and when

Before you start

What this needs.

  • A PHP website. Scheduled tasks run PHP files, so a static, Node, container or proxy website has nothing to run one with and the panel says so rather than creating a task that cannot work.
  • The file already on the website, in app, private or public_html.
  • Scheduled tasks in the hosting package, if the website belongs to a customer on one.

Step 1

Add the task.

Open the website, then Scheduled tasks, then Add a task. Give it a name, the path of the file to run, the five schedule fields and a timeout. Worked example, Laravel’s scheduler, which expects to be called every minute:

Name     Laravel scheduler
Script   app/artisan-schedule.php
Minute   *
Hour     *
Day      *
Month    *
Weekday  *
Timeout  300

And a nightly job at twenty past three:

Name     Nightly tidy-up
Script   private/cleanup.php
Minute   20
Hour     3
Day      *
Month    *
Weekday  *
Timeout  600

The schedule

Five fields, and what each accepts.

These are the five cron fields, in the usual order. They are kept as separate inputs rather than one line of text, so none of them can carry a newline into the crontab. Each accepts the same three forms.

FieldRangeMeaning
Minute0 to 59Minute past the hour.
Hour0 to 23Hour of the day, on the server’s clock.
Day of month1 to 31Day of the month.
Month1 to 12Month, as a number. Names are not accepted.
Day of week0 to 60 is Sunday. Names are not accepted.
FormExampleMeans
* * in Minute Every value. Every minute, in that field.
*/n */15 in Minute Every n-th value: at 0, 15, 30 and 45 minutes past. The step must be between 1 and the field’s maximum.
A list, with ranges 0,30 in Minute, or 9-17 in Hour, or 1-5 in Day of week Those values. A range must be ascending, so 17-9 is refused. At most 24 items in the list.

Four worked schedules:

Every minute            *      *     *  *  *
Every fifteen minutes   */15   *     *  *  *
Weekdays, 9 to 5, hourly 0     9-17  *  *  1-5
First of the month, 4am  0     4     1  *  *

What you type is not quite what gets written. The schedule is rebuilt from the numbers that were parsed, so nothing you send is copied into the crontab verbatim: 0, 30 is stored as 0,30, spaces around values are dropped, and a field the parser cannot make sense of is refused rather than quietly accepted.

The fields

What each input means, and what it refuses.

FieldWhat it is forLimits and refusals
Name How you will recognise the task in the list. 1 to 60 characters. Control characters are refused.
Script The PHP file to run, as a path relative to the website. Must end in .php, and must be relative and already normalised: a path needing repair is refused rather than tidied. It must live in app, private or the public directory. Letters, digits, dot, dash and underscore only.
Schedule The five fields above. Each required, each at most 64 characters, each within its own range.
Timeout How long the task may run before it is stopped. A task that hangs would otherwise still be running when the next one starts. 10 to 3600 seconds. Left empty it is 300. Outside that range it is refused.

A website may have 10 scheduled tasks, and the hosting package may allow fewer.

Where to put the file

private or app, not the public folder.

All three are allowed, but a script in public_html can also be reached by anybody who guesses its address, and a maintenance script that runs happily once a night is rarely one you want run a thousand times by a stranger. Put it in private or app unless it genuinely needs to be served as well.

Tasks run as the website’s own account, with the same confinement as its PHP, so a task cannot reach another website’s files.

When one is refused

Reading the message.

The panel checks what it can while you are still on the form, and then the privileged part of Dashmox checks the schedule and the script again before installing them. It is the validator of record: if it refuses, the task is removed rather than left showing in the panel as something that is not actually installed. A task you can see in the list is one the server really holds.

What it saysWhat to do
scheduled tasks run PHP, so enable a PHP runtime for this website first Change the website’s runtime to PHP, or put the job somewhere that can run it.
the script must live in the app, private or public directory Move the file. A script in logs, config or backups is refused.
the script path must be relative and already normalised Write private/cleanup.php, not /private/cleanup.php or ./private/../private/cleanup.php.
the minute field accepts 0 to 59 A value outside the field’s range, or a name where a number is wanted.
at most 10 scheduled tasks per website Delete one, or combine several into a single script that decides what to do.

Afterwards

Turning one off, and seeing that it ran.

A task can be disabled rather than deleted, which keeps the schedule and the path for when you want it back. What a task printed goes to the website’s logs, so Logs is where to look when something ran and did not do what you expected.

All guides