Intro to Scheduling 0:00Alright, let's talk about scheduling. So you'll find that there are various tasks that need to be performed at an interval. Every month, I want to clear out this events database. Once a week, I want to notify all subscribers with their updates. These are tasks that should occur at a constant interval. And luckily, Laravel Forge and Scheduler make this really simple for us. For example, if I switch back to my local machine, let's create a quick dummy command. And I'm just going to call it add task command. It's nothing real world, just something to prove that it does work. Alright, so now we have our add task command. Creating a Dummy Command 0:31It's nothing real world, just something to prove that it does work. Alright, so now we have our add task command. I also want to make sure that I add it to start artisan.php. Artisan add new add task command. Alright, so let's give this a name. Why don't we just call it app add task. The description will be add a new dummy task. We do not need a constructor here. And now when the command fires, all we're going to do is create a new task. Task create.And now when the command fires, all we're going to do is create a new task. Task create. The name will be dummy task. And the description will be task added on. And let's use carbon here. Carbon now. And I will make sure that I import that full class up here. Alright, and that's really it. We don't have any arguments or options. So a nice quick proof of concept. Deploying and Verifying Command 1:19We don't have any arguments or options. So a nice quick proof of concept. Alright, so we know this works. Let's do a git add everything. Commit with a message of add new command for creating dummy tasks. And now we can push these changes up to GitHub. And because we have quick deploy turned on, these updates will automatically be reflected in our app. To make sure, let's ssh in. List the files. Scheduling the Command 1:42To make sure, let's ssh in. List the files. Go into our default site. And if we run php artisan, we should see at the very top. There we go. Here's our custom command. So now let's create a schedule for this command to be called at a certain interval. If we switch to the scheduler tab in our browser, this just so happens to be the correct path to artisan. However, just remember if you have a custom site,this just so happens to be the correct path to artisan. However, just remember if you have a custom site, you will want to replace that with your site name. And remember, if you're ever in doubt, just do a pwd in your application root. Alright, so let's run our custom command. And only for the demo here, I'm going to run it every single minute. So let's schedule the job. Also, I want you to note that by default, Laravel Forge will automatically run a composer self update every single night. So you don't have to worry about that at all. Confirming Scheduled Runs 2:27Laravel Forge will automatically run a composer self update every single night. So you don't have to worry about that at all. Anyhow, let's go ahead and check out our site. So let's manage it, view it. And remember, we need to browse to tasks. And there you go. So what I'm going to do now is just pause for a handful of minutes so you can see all of these show up. Alright, so I paused for just a few moments. But you can see, like a clock, every single minute,Alright, so I paused for just a few moments. But you can see, like a clock, every single minute, our command fires and we create a new task. So now you know that when you need to trigger any kind of operation at a given interval, Laravel Forge and Scheduler make this as simple as humanly possible.