How to Setup Laravel Cron Jobs

In this how-to, we’ll show how to set up Laravel Artisan Cron Jobs within the Servebolt Admin Panel. To start, head over to the Cron section of your Environment and click the “Add a cronjob” button.

Setting up the Cron Jobs

This screen allows you to set up the needed information for this cron job. We’ll go over each section:

Overview of adding a new cron job in the Admin Panel.

The Command Section

This section holds the actual command being executed by the cron job. The command we need to run looks like this:

php /cust/0/bolt_name/user_name/home/site/public artisan schedule:run

Don’t copy and paste the above directly! Replace the path with the complete path to your webroot and Artisan location. If you don’t know the path, you can find it by running the pwd command from the directory where Artisan is located over SSH.

The Schedule Section

The schedule section lets you set the interval your cron job should run. An example of running the cron job every ten minutes would be this:

10 * * * *

If you have trouble getting the cron timing correctly, you can always use this site to set it up in a way that suits you.

The Comment Section

This section is fully optional. You can leave it blank if you like. However, it can be helpful to add a comment if you have multiple cron jobs running that are very similar in setup. Using comments makes it easier for you to tell them apart. 

The Notifications Section

In this section, you can define what kind of notifications you’d like to receive with regard to this cron job. You have three flavors to choose from. The default setting, “None”, ensures you won’t be bothered by any notifications. The next one, “Errors”, will alert you by email whenever an error occurs. And the final option, “All”, will send any output generated by the cron job to your email.

Wrapping up

If you’ve gone through the steps outlined above, you should end up with a Laravel Artisan cron job looking like this:

A fully setup Artisan cron job in the Admin Panel.

And that also means you’re finished! If the job produces errors, follow this guide on how to find them!