-
-
Notifications
You must be signed in to change notification settings - Fork 1
Cron directory scripts
The runner can resolve short script names from a local cron/ directory.
This lets us write:
* * * * * hello
Instead of:
* * * * * php cron/hello.php
For ordinary script aliases, the runner looks for a file directly inside the project's cron/ directory.
These two crontab lines both resolve to cron/hello.php:
* * * * * hello
* * * * * hello.php
Using the current PHP binary automatically.
Any text after the script name is preserved and passed through:
* * * * * nightly-report "sales team" 2026-03
If cron/nightly-report.php exists, that becomes equivalent to:
php cron/nightly-report.php "sales team" 2026-03
crontab:
*/15 * * * * report "internal"
cron/report.php:
<?php
[$script, $audience] = $argv;
echo "Building report for $audience", PHP_EOL;This style works well when we want a self-contained PHP script that still feels local to the project.
Ordinary script aliases only resolve files that are direct children of cron/.
For example, this works:
* * * * * hello
But this does not use ordinary script alias resolution:
* * * * * reports/daily
If we need nested directories, query-string input, or dependency injection, use a go() script instead. That workflow is covered in Go function scripts.
If the alias does not match a local cron/*.php file, the runner leaves the command unchanged. That means:
- a real shell command can still run normally
- a typo in an alias will not silently correct itself
For the more integrated cron script style, continue with Go function scripts.
PHP.GT/Cron is a separately maintained component of PHP.GT/WebEngine.