Introducing Forge Scheduler 0:00Let's take a look at the Laravel Forge scheduler. So if you're working with your server, you maybe want to perform specific tasks at a very specific interval. So for example, every night you want to run a specific command to send backups to DigitalOcean. Or every hour you need to perform some cleanup script to remove temporary files. When you find yourself in a situation like this, the Laravel Forge scheduler can help you with it. It allows you to specify a command and a user, and a frequency or interval at which this command will be run with this user. When you create a new server with Forge, you will automatically have one scheduled Laravel Scheduler Context 0:43command will be run with this user. When you create a new server with Forge, you will automatically have one scheduled job available, which is taking care of the Composer's self-update command. So this command runs every night and ensures that Composer on your server stays up to date. Now if you are used to the Laravel scheduler, you will have some code like this. So this is just a demo application which has a schedule command, and here we want every hour to run this inspire command. Now in order to actually let it run every hour, we need to call the artisan schedule run command. So as a default, because this is so common for every Laravel project that uses some scheduled Creating Schedule Run Job 1:35run command. So as a default, because this is so common for every Laravel project that uses some scheduled tasks, when you create a new scheduled job, this will be the default for you. So what it does is it calls php with the default site, and there it calls artisan schedule run. The user that will be running this command is the Forge user, and it will be called every minute. So let's schedule this job. So now every minute, Laravel Forge will run this command for you, and if you have a Laravel application running here, you can just use the artisan scheduler and define all your Viewing Job Output Logs 2:16So now every minute, Laravel Forge will run this command for you, and if you have a Laravel application running here, you can just use the artisan scheduler and define all your recurring tasks in the kernel schedule. If you want to take a look at the output of one of the previously executed scheduled jobs, you can click this button. Here you can see the output log of the composer self-update, so the last time this command was run, so last night, this was the output. So I was already using the latest composer version, and it didn't update itself. You can choose between a number of presets when defining the frequency, so every minute, hourly, nightly, weekly or monthly, or if you want to have some more flexibility, you Setting Frequency and User 3:04You can choose between a number of presets when defining the frequency, so every minute, hourly, nightly, weekly or monthly, or if you want to have some more flexibility, you can click custom, and just define your own schedule by using the cronjob notation. For most commands that you run, the forge user should be fine, but if you have a command that requires you to be the root user, like with the composer self-update, or maybe you have different users on your server, you can easily change the username here, and schedule a new job. And if you no longer need one scheduled job, just press the axe, confirm that you really want to delete it, and it's gone. Defining scheduled jobs on forge-managed servers couldn't be easier.want to delete it, and it's gone. Defining scheduled jobs on forge-managed servers couldn't be easier.