CompTIA Linux+ XK0-005 – Unit 08 – System Maintenance Part 3

  • By
  • August 8, 2023
0 Comment

20. Demo – Backing Up with dd

Well, we’re going to look at using DD to do some of our backups. And what we need to know is the name of the device that some of our hard drives are mounted. So we need the Cat command to throw out some information about our different devices. And what I see here is I have the SDA One, that is one of our devices that’s available for me to use, and SDA Five, which is one that I use to create a swap file on. So it’s got some information as well. What we’re going to do is we’re going to do a backup of something that would normally not be our choice. I’m going to back up the SDA One drive and put it into my home directory, which unfortunately is on the SDA One drive.

Normally you would be backing this up to some other type of media tape or CD or DVD or something else. But due to limitations of what we have, we’re going to give that a shot and see what happens. So this is something that has to be done with the permissions of the route. So we’re going to use DD and the input file is going to be the device, the SDA One and the outbound file is going to be, as I said before, my home directory slash the name of it MBR dot DD. The block size is going to be 512 and the count is going to be equal to one. And I’m going to hit the enter and we’re going to wait for that stuff to happen. Let me put in the password and well, that seems to be pretty quick and straightforward.

Let’s do an LS now of our directory and there is our MBR dot DD. Now the good news was, because I kept the count to one as far as the the size, I didn’t take the entire contents of, of that drive. So I basically took that one block, that one block of size 512 had. I redone that same command with a count of 1000. The bad news is when you’re hitting the number keypad, you sometimes want to make sure you have the numb lock button so you don’t get those funny little characters like you just saw. Anyway, if I tried that and put that in there, then you would see a different size because it’s getting more of the information.

But like I said, I could possibly corrupt things if I’m not careful in the fact that I’m copying from the drive and putting it on the same drive that I’m copying. But that’s just how easy the DD is. You just need the input file, the output file, which includes the path of where it’s going to go, block size, the count of what you’re going to grab, basically how many of those blocks and be done with it. Now you do need to know the geometry of your drive to be able to get gather all of the information. But as I said before, one of the nice things about that particular program is it does a true sectorbysector copy.

21. Topic B: Scheduling Tasks

Alright? One of the things we like to see as an administrator is how can I reduce the amount of work I need to do? The easy way is hire somebody to do it for you. But in lieu of that, which would be great as well, is scheduling tasks. And so that’s what we’re going to do. We’re going to talk about how we can schedule a task as a one time task or as an ongoing type of a task to get rid of the daily maintenance, daily mundane tasks that need to be done so that we don’t have to actually stop what we’re doing and say, oh, I forgot. I have to run this program. All right, so we’re going to look at the options we have for setting that up.

22. Scheduling Commands

Now, there are two general commands that you’re going to use to schedule any type of task. The once only is a command called at, and you’ll like at. It’s pretty straightforward at this date, and this time do this job. And then there’s cron. Now, Cron is well known as a popular Unix Linux command. That is a scheduling command that allows you to put in repeated schedules for whatever activity you want to do. We often call these activities jobs, tasks, job, whatever you want to do. You generally hear people talk about looking at the job report to see if whatever they’ve scheduled has actually ran, if it ran successfully, or whatever else. Anyway, those are the two general commands, at and Cron.

23. The at Command

Now, when you use the at command, it is a one time only and you can ask it to even do things like email the results or to log what it does. The time notations are pretty straightforward. You can say at like 10:30 p. m. At midnight at tomorrow at now, plus two days, saying two days from today, or the most obvious at 430 on this day eight, do this job that is straightforward. Now, I like to tell people at is fun. At would be one of these things where you say, okay, look, my friend’s on call. I know that he plans on going out on the lake on the boat, even though he’s on call. That kind of makes me jealous.

So I’m going to schedule a job at noon on Saturday when he’s out on the lake. Okay, don’t really do that. That was just a joke. You’ll get in trouble. But the idea would be to sabotage the system so he has to come back in. Hopefully he got the joke. Anyway, you can do these schedule these jobs for these times we call maintenance windows. So if you want to schedule a backup, you could do a onetime backup by using this command at a time that is reasonable. You know, 02:00 a. m. 03:00 A. m. Whenever you think there will be very few people on the server so you don’t interrupt their work.

24. Demo – Scheduling Commands with at

All right, we are going to execute a command at a scheduled time with the at command. But before we do, we need to know what the current date is and time so we can schedule our command command. So there’s our command, our time, it’s 1159. And what I’m going to do is I’m going to create an at command and I’m going to say at now plus 1 minute. I don’t want to wait very long. And now I’m in this mode where I can issue the command LSL capital F. And we’ll do that for the current Roots directory. And we’re going to redirect it to a file called Testing TXT. And I’m going to enter, I’m going to type in Control D to exit that interactive, and it says it’s going to perform that at 11:00.

So we’re going to hit the date command and see when it hits that time. And if it hits that time for us pretty quickly, then we’ll do a cat command. Oh, wow. It says it’s 11:00 exactly now. Well, you know what? I’m just going to wait until it’s a couple of seconds passed and then we’re going to do a cat command to actually, I’m going to try the LS and see if if that command is there. There it is. There’s testing dot text. And so let’s do the cat Testing TXT. And there it is. It’s filled with all the stuff that we would expect to see. So there I created a command to run at a certain time. It runs only once and then it doesn’t run again.

25. The cron Command

Now, the Cron command, similar to at, is to schedule a task or a job. Now, we use the Cron command to be able to say, basically, I want these things done on a repeated schedule. Weekly, daily. Whenever you want it to run. You basically have to set up what and when you want something to run. Now, we’re going to see these stored under the Cron tabs folder, and you can see it under the etsy file cron tab. And look at the status of the daemon with the Cron D to see if it’s running. But it’s a straightforward set of commands that says, as I’ve said already, whenever I need this run, do this job again, it could be monthly, it could be daily. It’s just however you set it up on a frequency that makes sense for your business. Bye.

26. Sample crontab

So if we were to take a look at the Crontab file after you schedule these, basically it’s a text file, and it would tell you what your schedules are. You might see something that says as a descriptor first. You’ll see, the descriptor might say, run five minutes after midnight every day. OK, so then we go down and we read what it’s actually going to do and it tells you when it’s scheduled. It tells you what the job job is and what the results are, as far as if you’re doing a backup or whatever it is that job is. That’s what you’ll read as you’re going through the lines of the Cron tab. It’s just designed to show you what you’ve set up, what you’ve scheduled. Technically, you could probably sit there and edit this by yourself without using the Cron command to set up more of these jobs. Bye.

27. crontab run – parts Format

Now, when you read the Chron tab file, you’re going to have this long list that tells you all of the stuff you want to do. So if you were to read it from left to right, what you would see is basically the entry telling you the minutes, the hour, the day of the month, the month, the day of the week, and then finally the command that you want to run. That’s the frequency. You hear what I’ve said? It could be minutes, hours, which would be basically time. Day of the month would be a numerical on the first, on the 15th, on the 20th. The month would be numerically january, February, March, whatever it is. Day of the week, sunday through Friday, I think Sunday is zero. So that would make Saturday six.That would be seven days. Even though it sounds wrong, zero to six is seven, range of seven.

And then, like I said, the command. So an example might be for looking at this just depends on what you’re trying to run. If you want to run something every day, then you may not necessarily have a specific month and day, but the days of the week, sunday, Monday, Tuesday, Wednesday, everything you want to run for every day. If it’s something that runs once a day, then you probably would be specific about the times that it runs. Just again, it’s a matter of how you put together the command and the frequency and knowing how to read it. Should you be reading the Cron tabs? The Cron tabs file is your best way to know what’s been scheduled to run, especially if there are some jobs that you no longer need and you want to get rid of them.

28. Managing cron

So in managing your tasks that you schedule with Cron, you have to be able to know how to read the Cron tab file. Now, you can also control who is allowed to create these jobs and who is not by going in and configuring the Cron allow or the Cron deny files. Again, all of these are under the Etc. Or Etsy folder. Now, there are some machines, machines that are not on 24 hours a day, like laptops. And so it’s very difficult to run something like Cron when a machine could be turned off at the time the job is supposed to run.

So there’s another option, another command called Anacron that’s short for an Anachronistic Cron job. It’s great for the laptops that might be powered off, therefore not able to hit or follow a regular schedule. But we’ll when you turn this thing back on, if there’s something that was supposed to have run, but it’s past that time, then Anacron is going to go and say, oh, I got to run this job because I was turned off. And so it’s a great way of being able to schedule things for different types of environments where you’re not 24/7 with the power.

29. Demo – Scheduling a Job with cron

All right. Now we’re going to schedule some jobs with Cron and those are things that are going to occur all the time. So what I’m going to do is look at the current date and time. It’s kind of important because I have to schedule in the future something that’s going to run. And if I don’t know what the current time is now, I mean, it doesn’t mean I can’t make the schedule. It just means that you and I are going to sit there and watch for a long time, possibly waiting for something to run. So I’m going to hit the Cron tab and you can see that I have absolutely nothing in there as far as any scheduled jobs.

And I’m also in my favorite VI. Okay, so what we’re going to do is we’re going to type in a job that we are going to run. And what we’re going to do is of course fill it in as far as the job number and all this other kind of stuff. And we’re going to put it in based on our time that we just saw, in fact, just to verify our time. Because again, this is going to be one of the more important parts of what we do is to make sure that I get this time in the future. Coming up, it’s going to take me a couple of minutes to talk about it. So we’re going to try to shoot for about eleven seven, I suppose. So here I am back in my editing and what I’m going to do is I’m going to go in here and put in the information as far as the minutes.

So I think eleven eight is what I was looking at because it’s eleven four, the hour is eleven, the day of the month will be the 11th. The month itself is January and the day of the week is a Monday. And the command that I’m going to put in here is going to be to do the LS again, l capital F. And we’ll start at the, from the root directory I think is what we did on our at command. So we’ll root directory, redirect it to our dollar sign home and a file called Crontest TXT. Okay, so if all goes well, I’ve got the minutes, the hours, the day of the month, and everything else set up in there. And Control X takes me out and I’m going to say yes to modify what I have and hopefully that’s the right name of the file that I’m going to create the file name that I want to type in and that looks appropriate as well.

So with that information I’m going to hit enter. And I’ve got the new Chron tab set up in there. Okay? So now to look at it, I can do crontab l and see what I have set up for eleven, eight coming into that particular time to run that little command. And I’ll follow it up with a date command here to see that I have about a minute and a half to let that go on and do its job. Now, if I look right now and I try to do the Lslf, you can see that I don’t have a file here called Cron Tab, so it’s not available to me at the moment. And we’ll just have to keep waiting for that next little time for the eleven eight to occur. So after we see the eleven eight hit, we’re going to go take a look and see if the results of that file are there.

And then when we’re done, we’re going to delete that Cron tab file because we don’t need to keep doing that all of the time as we go through. So remember, Crontab L listed the jobs that you have. Crontab R would delete that file. And of course, looking at the date command, it’s still not quite there. Well, as much as they say, watching a pot will watch pot never boils. That’s how I feel. I couldn’t resist. I had to do the date command again, and I was just a bit early. I still had a couple more seconds there to let it go. I could be like that anxious little child waiting to do a certain event or activity or open a present. Ah, there we go, eleven eight. So, boy, with any luck, I can do my LS command and see a new file in there called the Cron Tab. And I’m looking through there.

Or cron test. There it is. I see it up at the top, Kontext TXT. So it gives me an idea that it ran. Let’s do a cat with the Crondest TXT file, and there’s the results of my output. Okay, so that was a scheduled job. It occurred and it would occur tomorrow. But I’m going to type in if I do Crontab L, you can see that it was one that was scheduled again and could be recurring. But I’m going to Crontab R, and now Crontab L again to show you that that job is gone, at least for that particular user, which is also important. All right, so that was scheduling jobs with Cron basically is what we would call it, or often, as we said, and I know some people like it or not, but we often call it Cron scheduling or creating a Cron job because you would look up the list of jobs that are running.

Comments
* The most recent comment are at the top

Interesting posts

Preparing for Juniper Networks JNCIA-Junos Exam: Key Topics and Mock Exam Resources

So, you’ve decided to take the plunge and go for the Juniper Networks JNCIA-Junos certification, huh? Great choice! This certification serves as a robust foundation for anyone aiming to build a career in networking. However, preparing for the exam can be a daunting task. The good news is that this guide covers the key topics… Read More »

Mastering Microsoft Azure Fundamentals AZ-900: Essential Study Materials

Ever wondered how businesses run these days without giant server rooms? That’s the magic of cloud computing, and Microsoft Azure is a leading cloud platform. Thinking about a career in this exciting field? If so, mastering the Microsoft Certified: Azure Fundamentals certification through passing the AZ-900 exam is the perfect starting point for you. This… Read More »

The Impact of Remote Work on IT Certification Exam Processes

With remote work becoming the new norm, it’s not just our daily routines that have changed but also how we tackle IT certification exams. Gone are the days of trekking to testing centers; now, your living room can double as an exam room. This shift has brought about some fascinating changes and challenges. Let’s dive… Read More »

IT Risk Management: CRISC Certification Exam Essentials

Do you ever feel like the IT world is moving at warp speed? New tech seems to pop up every day, leaving you wondering how to keep up and truly stand out in your field. Companies are increasingly concerned about online threats, data leaks, and meeting legal requirements. That’s where the CRISC (Certified in Risk… Read More »

The Ultimate Guide to Mastering Marketing Automation for Email Wizards

Hey there, email aficionados! Welcome to your new favorite read – the one that’s going to turbocharge your email marketing game. You’re about to dive into the captivating world of marketing automation, a place where efficiency meets effectiveness, letting you boost your campaigns without breaking a sweat. Get ready to discover how automation can not… Read More »

Master YouTube Marketing with These 10 Powerful Steps

Welcome to the dynamic world of YouTube marketing! Whether you’re a seasoned pro or just getting started, harnessing the power of YouTube can significantly boost your brand’s visibility and engagement. With over 2 billion monthly active users, YouTube offers a vast audience for your content. But how do you stand out in such a crowded… Read More »

sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |