Prev |  | Next

### 3.2.4. scheduled

??? hook functions are similar to ??? ones, except these functions do not require any input from the command line. The modules containing this hook are invoked by running `script.php` with the `--scheduled` argument (no module name is taken; this argument will run all scheduled hooks for all available modules).
Like the name of the hook already suggests, this hook can be used for creating tasks which have to be executed on a regular basis. To archieve this, you can let `script.php` run from a scheduling service (like a cron job on a UNIX system).
In general, ??? hooks are used for automating tasks you want to execute without having to perform any manual action. Practical uses for a scheduled hook could be:

- housekeeping (cleanup of stale/old data)
- daily content generation (like sending daily digests containing all posted messages for that day)
- forum statistics generation

Keep in mind that for using this hook, the module in which it is handled must be enabled in your admin interface. So if this hook is not running, the containing module might be disabled.
To run this hook from the command line or from a scheduling service, you have to be in the Phorum installation directory. So running this hook for your Phorum installation would be done like this on a UNIX system prompt:

    # cd /your/phorum/dir
    # php ./script.php --scheduled

When creating a scheduling service entry for running this automatically, remember to change the directory as well. You might also have to use the full path to your PHP binary (`/usr/bin/php` or whatever it is on your system), because the scheduling service might not know the path to it. An entry for the cron system on UNIX could look like this:

    0 0 * * * cd /your/phorum/dir && /usr/bin/php ./script.php --scheduled

Please refer to your system's documentation to see how to use your system's scheduling service.

Call time:

In the `script.php` when called from the command prompt or a script file with the `--scheduled` argument.

Hook input:

None

Hook output:

None

Prev | Up | Next
| Home |