Laravel Forge enables you to configure scheduled jobs that run commands at specified intervals on either a server or site level. You can choose from predefined frequencies or create custom Cron schedules tailored to your specific needs.
If your scheduled job fails to run, verify that the command path is correct and accessible.
To create a scheduled job, navigate to “Server / Processes / Scheduler” or “Site / Processes / Scheduler” depending on your requirements. Then, click the “Add scheduled job” button. Configure the command, user, and frequency settings, then click the “Create scheduled job” button to activate it.Server-level jobs are ideal for system maintenance tasks, while site-level jobs are perfect for application-specific commands like Laravel’s scheduler or custom deployment scripts.
To edit a scheduled job, navigate to the appropriate “Processes / Scheduler” section. Then, click on the dropdown next to the job you want to modify. Click the “Edit” dropdown item and update the job configuration as needed.
You can manually execute a scheduled job by clicking on the dropdown next to the job and selecting “Run”. This is useful for testing jobs or running them outside their normal schedule.Jobs executed via the “Run” dropdown option have a 60 second maximum execution length timeout. Regular scheduled jobs executed via cron do not have this timeout limitation.
To delete a scheduled job, navigate to the “Processes / Scheduler” section. Then, click on the dropdown next to the job you want to remove. Click the “Delete” dropdown item and confirm that you want to delete the scheduled job.
Heartbeats provide proactive monitoring for your scheduled jobs, ensuring they execute successfully and on time. This feature helps you identify failed or stuck jobs before they impact your application.
When creating or editing a scheduled job, enable monitoring by toggling the “Monitor with heartbeats” option. Once enabled, specify the notification threshold by setting the “Notify me after” value in minutes.Laravel Forge generates a unique endpoint URL that your scheduled job must ping upon successful completion. If Forge doesn’t receive a heartbeat ping within the specified timeframe, you’ll be notified that the job is missing or has failed to execute.
Your scheduled job should include a request to the provided heartbeat endpoint as its final step. This confirms successful execution and resets the monitoring timer. You can implement the ping using curl, HTTP libraries, or Laravel’s HTTP client depending on your job’s requirements.This monitoring system is particularly valuable for critical maintenance tasks, data processing jobs, and backup operations where timely execution is essential for your application’s health.Applications running Laravel can use the pingBefore and thenPing methods to automatically send heartbeats when using the Laravel scheduler. Read the Laravel documentation.
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.