 Alright, so this video is going to be on CronTabs, CronJobs, whatever, whatever you want to call them. Well, I mean, they're CronJobs and there's your CronTab. They're different. So, if you don't know what those things are, we're going to talk about that. But also, I want to talk about some of the CronJobs that I set up on my machine just to make life a little bit easier, just to optimize things a little bit. Now, first off, if you don't know what CronJobs are, they are, well, they're sort of a mainstay of Linux and Unix systems. The idea being, there are a lot of tasks sometimes that you don't want to run by yourself manually. You want to schedule for them to run at a particular interval, at a particular time, over and over again or something like that. So, CronJobs are how you do this on Linux or Unix or something like that. Now, most Linux distributions will come with some kind of Cron Manager by default. Arch Linux, however, doesn't. So, if you're an Arch user, you're going to want to install what's called Crony. There are a couple of different Cron Managers you can use, but all of them are really the same. Actually, I say that someone's going to give me crap for that, but they're really the same. I'm sure someone has some opinions on it. So, you can just install something like Crony or something else, and you also have to enable the service. So, PseudoSystemCTL enable Crony and PseudoSystemCTL start Crony, if you want it to start now before reboot. So, how do you actually schedule something? How do you actually play around with CronJobs, CronTabs, and what do I use for them? So, now to update your CronJobs, you have to edit what's called your CronTab. And to do that, you can just run CronTab and then with the E option. And this will bring up a list of all the CronJobs you have queued or however you want to think of them. Now, if you're just installing this, this should just be a blank file. So, don't sweat that if there's nothing there. So, here are the commands that I have running. Let's go ahead and talk about this. So, notice the syntax of it. So, the stuff in orange is of course the command. And then to the left of that, there are actually five different elements. So, one, two, three, four, five. So, let's talk about what this means. Now, as an example, I'll actually take this one and I'll move it down so it's a little more visible. So, I have a script that I call DateLog. And what it does is I have it run every single minute. And it basically keeps a running total of all of the minutes that I spend on my computer every day. So, since Cron is running this every minute, I have a log somewhere of all the days that I've been on the computer and how many minutes I've been on. That's just a habit just because why not? So, this runs every minute. So, what is all this stuff to the left here? So, what these, this is really a time of day and time or which days you want this to run on. So, the first element is the minute you want it to run. The second is the hour. The third is the day as in day of the month like 1 to 31. I had to think about how, I didn't have to think. Sometimes you forget how words are pronounced though. So, your minute, your hour, your day, then a month that is 1 to 12. And then a day of the week as in Sunday to Saturday where Sunday is 0 and Saturday is 6. So, this command, I want to run every single minute that I'm online. So, that's why it has a cleaning star here or the asterisk. This means it's running every minute of every hour of every day of every month and every day of the week. That's what this means. Now, let's look at one of these other ones. So, I have, for example, NewsBoat is my RSS feed reader and I want it to update RSS feeds automatically refresh with this command every 15 minutes or so. And this is what this command does. Actually, let's talk about the other one first because these two, I'll go ahead and say, are doing the same thing. They're running a command every 15 minutes. This one is to update my RSS feeds. This is to update my music database with MPD. Now, if I want, so what do I mean by these are the same thing? Now, they're still running every hour, every day, every month. But if you look at the MPC update command, what I've specified here for minutes is I wanted to run at the top of the hour, 0 minutes after, then 15 minutes after, then 30 minutes after, then 45 minutes after. So, that effectively means every 15 minutes. So, another way of doing this would actually be to use this syntax here, where it's basically every minute divided by 15. So, these two commands are more or less the same. I don't know if it's actually every 15 minute interval. I think it's each one that's divisible by 15. I think that's what that means. But either way, these are basically more or less the same thing. Now, let's talk about changing these commands. Hypothetically, let me move this up because we're not going to use it anymore. Let's say, with my RSS feeds, let's say I only want them to update on days of the week, or like weekdays, like Monday through Friday. I don't want any, I don't want to have to deal with the internet every on Saturday and Sunday. Now, in order to do that, we can change the day of the week. And as I said, 0 is Sunday and 6 is Saturday. One way we could do it, one bad way, well, not bad, it works, but one clumsy way to do it is just list out all the other days. So, Monday, Tuesday, Wednesday, Thursday, Friday, all numbered. That's one way to do it. But that's the same way, that's the same thing as saying one through five, right? So, if I were to save and close out of this, this would basically, it would be reloading news boat every 15 minutes of every hour, every day of the month, every month. But only on weekdays. That's what that would be doing. Okay, so that's what that's about. So, these are the commands I have. As I said, I have a date log here. I have another cron tab I'll show you in a second. That's my root cron tab, but this is what I have here. So, I have the news boat update for my RSS feeds. I have my music thing. I have my date logger. And this thing here is my music. Well, actually I should explain, or not my music, my email. I should explain what this is about. This is my email refresh command. And you might notice up here every three minutes or so. Well, literally every three minutes, because this is running every three minutes. There's a little icon that says I'm updating mail. And this script deals with that. So, this is to update my mail. What all this is about is this is specifying what screen, what display, basically I'm using for this command. Because if this command finds new mail, it's going to send a notify send command to appear up here. And it's going to say, you got new mail. Actually, let me show you how that works in action. I'm not going to show you with the mail script, but let's make up a cron job just to learn about it. Let's say, so it's 9.31 right now. Let's say we want to command the run at 9.33. So, it's going to be 33 minutes after. It's going to be 9, actually it's not going to be 9, it's going to be 21. I should say the hours are on 24 hour time. In fact, let's actually specify what specific day we are on. We are on August the 4th, so I'm going to put a 4 here. 8 for the month. And then day of the week is, what is it, Saturday. So, I'm going to save that. It might be a little too late. I think I have to quit for it to actually load. So, that should show up within a minute. And while that's working, I am going to... Oh, actually, I didn't actually give it a command. I'm retarded. So, I was going to put notify send, and we'll just have a command. This is a cron command. And I'll change that because I don't know, we might be running out of time. So anyway, I'm going to say cron... While that's loading, I'm going to open up my root cron tab, just to show you what I have here. The two commands that I have run as root. Now, to get to this, I just ran sudo cron tab. But the two commands I have is... First off, I have update db run. Now, if you don't know what that is, this is... Oh, there's my mail reloading. Sorry. That's again one of the scheduled tasks. If you don't know what update db is, basically there's a command on Linux called locate, which is a very efficient find command because it indexes all of your files so they can be searched really easily. So I can run the locate command and then find, you know, secret file, which I actually added before this video, and it immediately finds it. But in order for locate to work and work so instantaneously, you have to update your database. And that's what this is. I have it run every 30 minutes, which I could rewrite as being, you know, slash 30 or something like that. So anyway, that's one command I have run, running. And another command I have running, which might be of use to archer users, is this pacman command. Now, when is this running? I actually have it run every five minutes after... Oh, there's our cron command working, so that worked out perfectly. But I have this run every five minutes after the hour, and that's just to avoid conflicts with other crons that are running at the top of the hour. And it runs every two hours, as this says. And what it does is it runs pacman update with the w option. And what that means is search for new updates for my packages online, but go ahead and download them, but don't actually install them. And no confirm is just to hit yes, so it doesn't, like, try and ask the invisible user if you want to continue. So this command, every two hours, five minutes after the hour, basically just downloads all of the updates that happen to exist, and I can easily install them later whenever I want. Notice also I have this command, which this really just updates i3 blocks. So I have this little notifier up here with packages. It ends up I have nine packages that I could update. And if I click on this, well, I should say once this command runs, this little pkill command basically just tells i3 blocks to update its estimate of how many packages I have. And I'm going to click on this, and what I have it run, this isn't part of cron, but what I have it run in my system is do you want to go ahead and install all these programs. And notice I've already downloaded all these, so if I press enter to continue, it's really just going to immediately install them because this command downloaded them for us. So that's about it. So yeah, so those are my cron jobs. I hope if those of you who are new to cron, there are lots of things you can play around with it and do. And yeah, so hopefully, for those of you who already knew about it, this gave you some ideas of the kind of stuff you can do with it, or at least the stuff I like doing with it. Anyway, so that's about it, and I'll see you guys next time.