 Hey everybody, welcome back to the channel. Today, we're going to talk a little bit about Kron. So if you don't know what Kron is, chances are you probably don't need it, but maybe you do. So let's just talk about Kron as basically a service that runs in the background on every Linux computer that allows you to automate certain processes. So you can do this on Windows and Mac as well. They're called different things. So like Mac has Automator, Windows has Windows services. I don't know much about the Windows one. I've used Automator in the past, but those are for different things. Kron is basically can run any command that you give it at different periods of time, whether it's daily, hourly, whatever, and I'm going to show you different intervals and stuff like that in here in a few minutes. But basically, let's say you wanted to run a backup every day at midnight. You could do that with Kron. Let's say you wanted to check the weather once an hour and have that input it into a file, which should be then checked for by, you say, your status bar like Polybar or whatever, you could do that. That way, it's not checking every 30 minutes or whatever, it's just checking once an hour. It also, you could do something like check for updates once a day or once a week. And it could be completely automated and you wouldn't have to, you know, do it yourself. So that's basically what Kron is. So the question it becomes is how do you use Kron? And Kron is a little complicated for people. So sorry, I switched to some new key bindings for OBS and I'm still learning them. So bear with me, I'm probably going to switch around to the wrong things once in a while. So let's see if I got this right. So ha-za. Look at that. That's cool. All right. It took me long enough to figure out how to do key bindings in OBS. So this is Kron Guru. We're going to talk about that here in a minute. But basically, Kron curse pop-ups, like I said, allows you to automate this test. So it's done through a thing called Kron tab dash E. So if you want to set a Kron job, you have to run this tab here. Kron tab dash E. I'm almost positive that every Linux distribution comes with Kron tab and Kron and stuff installed. If not, it will be in your repositories. Just run Kron tab dash E. If it works, chances are, you know, you have an installed don't run Kron tab with a different editor. It's going to open up a version of nano, but it's a specialty version of nano. If you've ever installed Arch Linux, you'll know that there's a specialty version of VI that allows you to edit the sudoers file. It's kind of like that. You want to use just Kron tab dash E. You don't want to navigate to the file itself and use like Vim or something. It wouldn't work. I'm not sure if it would break something. I've never tried. I don't want to try. Just don't do it. Just use this thing here. Let me zoom in here so you can actually see Kron tab dash E and you just hit enter. And this is my Kron tab file. It's located into dash TMP. I'm not sure why it's located in that folder. It's just where it's located. Let me go over some of the things for here. So first it tells you what your default shell is. My default shell is not bashing anymore, but I have bashing installed so you can leave it that. I haven't been using fish. I could change it to fish if I wanted to. I'm not going to. I'm just going to leave it because I know this works. The mail to here. Yes, that's my email address. I don't care if you really want to email me, whatever. It's just going to go to spam. That basically what Kron will do is if something fails, it will email you that your Kron job failed. So you could also give it pretty much any email you want as long as you can have access to it. This last one here is really important if you're going to be running scripts. So you want to tell Kron what your paths are. So if you've ever seen the dollar sign path thing, you can actually go through. If you don't know what your paths are, basically, how do you explain path? It basically allows you to run scripts directly instead of having to do funky things with the whole path. It basically is just the default. I don't know how to explain it. Paths are really hard. I might have to do some, I mean, it's really hard to explain what a path is. I'm talking about path, not talking about like slash documents. You know, that would be a path. But I'm talking about the path with a capital and it looks like this. So if we do echo dollar sign path, it'll tell you everything that's a path on your site. You can put a script in any of the one of those these things, and then you can run it from anywhere on the system by just typing the name of the script. So I have a script in slash user slash local slash bin called weather dot pi. If I run that, it gives me the weather. Very simple. With Kron job, if you're going to run any scripts, you want to give the most usual paths on your system, usually there have been as been user slash bin and so on and so forth. There's a whole bunch of them. You don't have to get them all just specifically the folders that you're using to score store scripts in. That will allow it to just run the path or the script without having to have a whole bunch of paths, you know, in crazy places. And it works really well. So I have three Kron jobs currently. I have one that runs hourly, it runs weather dot pi and then it appends that to the end of dot weather in my home directory. And then my SL status up here will actually display that. I did that because if I just let SL status run the script, which you can do, it checked like every five seconds or maybe every thousand milliseconds or something like that. It's checked way too often took a lot of resources. This way it only checks an hour. And despite the fact that SL status still checks every thousand seconds or something, it just keeps it the same. That way I don't have to deal with it switching back and forth every thousand milliseconds. It was very annoying. I also have something that shows the updates, the number of updates I have on my system and it does basically the same thing. It only checks it once a day. I don't need to know how many updates I have every hour. And this one here just runs MailSync, which is for MailWizard. Anyways, those are the ones that I have. So what I'm going to show you now is how to set this up just for backup. I want to do an R sync. So this is where Pronguru comes in. So if we go here, this is crontab.guru. And this basically gives you a way of setting it up without having to remember what all these things are. So I don't have one of these in my thing in my crontab because these are very complicated. So basically the first column here is minutes, hours, days, month, week. So the way this says here on the fifth minute of every hour, the fourth hour of every day, whatever this thing would run. That's when cron would run this thing. So you can change these things right here in crontab. So if I wanted to do it at the zero minute of every hour, I would just do it this way. So that would do it at minute zero of every hour of every day. So if I wanted to do it at one, two o'clock in the morning, at the beginning of two o'clock every morning, that's what that would look like. Personally I like the ones that I have here. So I think it goes on this one, oops, wrong one, where, seriously, there we go, there. I was on two. I didn't know where it was at, seriously. You can change your key bindings that you're used to because it takes a long time to get those muscle memory back down. I like these here. So if you're doing hourly, daily, or weekly, you can just do at daily, at hourly. And basically what that will do, hourly will run it at the zero minute of every hour. So one o'clock, two o'clock, and so on and so forth. Daily will run it at midnight, right on the dot, and it will do it every day. So I like those. This one here runs every 10 minutes. So there's a lot of different things you can do. I'm not going to go through all of them. That's why Kran Guru is so good. So if I, if we go here and do one star, so that is, star basically means every, and then 10 minutes of every hour, that every 10th minute. That basically means it checks my mail every 10 minutes. You can change it to 20 minutes, every 30th minute, so just like, you know, whatever. You can do that for every single one. So if we delete these here and do star slash 10, that would do every 10th hour. Every minute passed every 10th hour. It'd be kind of weird. So you want to put like a zero on this. That way you would put, you know, at the zero minute of every 10th hour, it would do this thing. You can also do ranges. So you can do, let's do one through 10, oops, one through 10 of star. So it's every minute from one through 10, it would run this thing. I'm not sure why you'd want to run a thing every 10, you know, every, the first 10 minutes of every hour. I'm not sure what script you'd be using to do that, but you could do that. This is more, this is more useful with months and days. So if you wanted to go through and do, this is month here. So every, I think if you do every, like the star dash two, this is every second month. So it'd be every other month you could do. You could do ranges of, if say you only wanted to run something, only the first half of the year, you could do one through six and so on and so forth. Or if you wanted to do something for the days, you could just do one through four. And that would do every minute on every day of the week from Monday to Thursday. That's how that works. And then you just, what you want to do is you can just copy that, move your crown tab, copy it into here and then script. That's all crime does. And then it would run this thing to whatever you set it as with those stars. And that's where crime is. So what I'm going to do actually is just something really easy. Instead of using the crazy star system, I'm just going to go do that. So I'm going to do that daily. And I'm going to do rsync dash AV dash dash delete slash home slash. And then I'm going to give the path to my backup folder, which is at run media slash. Hmm. I don't know if I have to use how I would do spaces in this. I'm not, I can't remember. I think it's the same way you'd use it in bash. So big slash slash boy, which is the name of my hard drive, because it's a big hard drive, or at least it was when I first got it. It's not so big anymore. And then back ups, ups slash 2021 slash Jan April. Okay. And then following slash pretty sure that would, that's going to run just fine. Um, I could, I will test that off-screen mixture. I don't want to, but pretty, pretty sure that would run just fine. I may end up having to take that space out, but that's just the way that's the way you said, that's the way you set up contact. It's very easy once you get past the weird syntax. And that's why crime guru is so awesome. I will link this in the video description. Uh, it will, it just allows you to set up things the way you want it. And it tells you exactly how it's going to come out in plain English. It's awesome. Definitely use it. Don't bother going through and trying to learn these things on your own. I mean, eventually you'll learn them. You'll pick it up, but to start off with this, it's an easy tool to use. And it's just, like I said, it's awesome. So that is it. Keybindings, keybindings for the win. It's awesome. All right, anyways, uh, if you enjoy this video, give it a thumbs up. If you didn't give it a thumbs down, uh, you can support the channel in any number of ways. The easiest way to do so is by hitting the subscribe button. And that's the red big red button just underneath the video here. Uh, and then hit the notification icon. Completely free, totally easy to do. If you are interested in supporting other ways, you can follow us on Twitter at the next cast on Twitter and Facebook. You can follow me personally. I am at MTWB, uh, and you can also support the channel on Patreon at Patreon.com slash Linux cast. I will see you next time with another video. Thanks for watching.