Skip to content

Cron directory scripts

Greg Bowler edited this page Jun 22, 2026 · 2 revisions

The runner can resolve short script names from a local cron/ directory.

This lets us write:

* * * * * hello

Instead of:

* * * * * php cron/hello.php

How alias resolution works

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.

Passing shell arguments through

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

A small example

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.

One important limitation

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.

When the file is not found

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.

Clone this wiki locally