crontool
Paste a schedule, read it in English, see the next runs.

Run a PHP Script with Cron

To run a PHP script on a schedule, call the PHP CLI binary with the absolute path to your script. Use the command-line PHP (not a browser URL) so the job runs even if no one visits the site.

The crontab line

Run crontab -e and add (every 15 minutes):

*/15 * * * * /usr/bin/php /var/www/app/task.php >> /var/www/app/task.log 2>&1

Use the CLI binary

Find it with which php (often /usr/bin/php). On servers with multiple versions use the exact one, e.g. /usr/bin/php8.2.

CLI vs URL

Prefer running the script file directly over hitting a URL with curl — CLI has no web timeout, no memory limit from the web server, and runs regardless of traffic. Use curl only when the logic must run inside the web app context.

Fix 'php: command not found'

Cron's PATH is minimal. Always use the absolute path to the binary rather than bare php.

FAQ

How do I run a PHP file every X minutes with cron?

*/15 * * * * /usr/bin/php /path/task.php runs it every 15 minutes. Change */15 to your interval and use the absolute path to the PHP CLI binary.

Should cron call PHP by URL or by file?

By file with the CLI binary in most cases — no web timeout or memory limit and it runs without traffic. Use curl to a URL only if the code needs the web request context.

Why do I get 'php: command not found' in cron?

Cron's PATH doesn't include your PHP binary. Use the absolute path such as /usr/bin/php or /usr/bin/php8.2 (find it with 'which php').