Technical article
Cron jobs on shared hosting: maintenance without a critical dependency
Use cron for cleanup, reports and repeatable maintenance tasks, but not as the only confirmation mechanism for critical business flows.
- Deployment & operations
- Cron
- jobs
- shared
- hosting
- maintenance

In this article
Cron can start Laravel maintenance when the host allows the required PHP CLI, frequency and execution time. The scheduler selects due work; it does not prove completion. Make missed, duplicate and interrupted runs visible.
Check the host before scheduling
Compare PHP CLI and extensions with the web runtime. Use absolute paths and the correct working directory. Confirm minimum frequency, process limit and log location. One scheduler call per minute is Laravel’s usual setup; a lower frequency may miss short scheduling windows.
* * * * * cd /home/USER/domains/example.com/laravel-app && php artisan schedule:run >> /dev/null 2>&1Adapt USER, domain, directory and php to the host. The entry suppresses output; use a private rotated log during qualification. Never expose logs publicly. Test configuration with a harmless task without customer actions.
Illustrative cleanup that may run again
use Illuminate\Support\Facades\Schedule;
Schedule::command('app:cleanup-temporary-files')
->dailyAt('03:15')
->withoutOverlapping();app:cleanup-temporary-files still needs implementation. Select only expired temporary files from one directory, in small batches. Record start, end, count and last success without contents. Resume without touching active uploads. An overlap lock does not prevent a later repeat; the task itself must be repeatable.
Monitor completion, not only launch
withoutOverlapping uses cache locks: verify storage and expiry. Monitor the last successful completion. Test an interruption with dummy files. Local times around daylight-saving changes may repeat or disappear; choose UTC where possible or define task behaviour for that situation.
Example verification: PHP fragments were syntax-checked with PHP 8.5.11. Laravel execution and hosting behaviour were not tested; use a suitable test application and configuration.
Last updated:


