Cron jobs
Schedule recurring PHP scripts from the hosting panel.
Schedule a cron from the hosting panel
- Open the hosting panel from your dashboard.
- Click Cron Jobs.
- Pick a schedule from the dropdowns (every five minutes, hourly, daily…) or type a five-field crontab line.
- Set the command. The hosting panel exposes
phpdirectly, so you do not need an absolute path. - Save.
Run a PHP script every hour
0 * * * * php $HOME/public_html/cron/refresh-cache.php >> $HOME/cron.log 2>&1
Tips
- Redirect output (
>>and2>&1) to a log file inside your home directory. Without it, errors are silent. - Use the
$HOMEenvironment variable instead of hard-coding the path. It stays valid across plan changes. - The working directory is your home, not
public_html. - The panel may rate-limit how often a cron can fire. Once a minute is the floor on most installs.
Detect cron context
if (php_sapi_name() === 'cli') {
// Running from cron
}
HTTP-trigger alternative
If the panel’s cron is restricted to longer intervals than you need, expose a small PHP endpoint at /private-cron.php protected by a long random query token, and call it from an external scheduler like cron-job.org or GitHub Actions on the cadence you want. Verify the token inside the script and refuse anything else.