What you’ll need
- DirectAdmin access
- Your DirectAdmin username (for paths)
You’ll create a task that writes a timestamp to a log file every five minutes. Once that works, swap in your real task.
Steps
Step 1: Create a folder outside public_html
In System Info & Files then File Manager, create
/home/USERNAME/tasksand/home/USERNAME/logs.Step 2: Write the task
Create
/home/USERNAME/tasks/heartbeat.php:<?php $line = date('c') . " heartbeat ok\n"; file_put_contents(__DIR__ . '/../logs/heartbeat.log', $line, FILE_APPEND); echo $line;Step 3: Open Cronjobs
Open Advanced Features then Cronjobs.
Step 4: Set the schedule
Minute
*/5, and*for hour, day of month, month and day of week. Cron schedule syntax explained (with examples)Step 5: Enter the command
/usr/local/bin/php /home/USERNAME/tasks/heartbeat.php >> /home/USERNAME/logs/cron.log 2>&1Replace
USERNAMEin both places. Create the job.Step 6: Wait and check
After ten minutes, open
logs/heartbeat.log. You should see two timestamped lines.Step 7: Replace with your real task
Edit the command to run your real script, keeping the log redirect until you’re confident it works. Running PHP scripts from cron: paths, output and common mistakes
Step 8: Remove the test
Delete the heartbeat job and files.
Check it worked
heartbeat.log gained a new line roughly every five minutes, and cron.log contains no errors.
If something goes wrong
| What happens | What to do |
|---|---|
| No log lines at all | Check the schedule saved, and the full paths. Cron job not running |
| cron.log shows ‘No such file’ | Wrong path or USERNAME not replaced. |
| cron.log shows ‘command not found’ | PHP binary path differs. Running PHP scripts from cron: paths, output and common mistakes |
New to Traxio? The PHP hosting page lists the PHP versions, database and tools every account gets, free for the first 30 days.