If there is one thing we can focus on the most, agree that the technology of choice is computers that are constantly changing. You quickly learn Java Spring, then Boot, finally Spring, and AngularJS. soon And AngularJS will be deprecated to improve Angular a lot. before
But so far, one part of free programming has remained the same: activity planning. Since its inception in 1977, cron has been a popular solution for scheduling repetitive *nix tasks on Sprinting systems.
If you are applying for a reputable certification, Linux+, or a career very similar to Il linux, it is important that you have a good understanding of the cron methods and how they work.
For those who are not in the know, you might think about what “p”job” can be assigned to Cron. Don’t worry, we’ll walk through it. Once my husband and I have a concrete example, we’ll share the syntax of cron and finally walk through ours just to illustrate. Without further ado, let’s look at cron and an example.< /p>
What Is Cron?
Cron is simply a scheduler based on the time on the Linux worker stations in use. While this definition may seem simple enough, there is more to it than that: after all, time can be measured in dozens of ways. If the mission is launched an additional twenty minutes a day each or at 22:00. Last Friday of the month? Yes, this last schedule can sometimes be set up with just cron. To make things more concrete, let’s look at an example related to a job that cron requires.
What Is Work?
Let’s say Kron becomes a software developer for several giant insurance companies. For companies, there areThere is a retention policy for customer requests. Each time a customer completes an automated online questionnaire, it is stored in a different database for one year. It will then likely be removed in accordance with the previously mentioned maintenance policy.
With a large number of jobs running on the last Friday of every month, you and your team have decided that now is the time to remove the old database records from the database. In other words, once a month after deleting all records older than one year. . It must be
Unfortunately, the task will be launched at midnight. There is no doubt that the last person of the month every month wants to be awake until midnight on the last Friday, and cron comes to the rescue here. No human intervention required! Today I want to see how it can be done.
How Do You Run This Cron?
Cron jobs are easy to run, but they require careful attention to detail to ensure they run correctly. A misconfigured cron can be a complete disaster if left unattended.
For example, tasksand with memory intensive usage, which is scheduled to train every month, may not be properly configured to run every minute. This can lead to broken servers and is notoriously hard to fix. Therefore, make sure that the tasks are thoroughly tested before using this method in a production environment. photo Some
The following paragraphs are an example of what you can do while reading the cron command:
As we mentioned earlier, there are five intervals when considering a cron job. time The shortest is treated as an integer asterisk on the left (a.N.A.Placeholder), usually in the interval of minutes. The most accurate placeholder is the day associated with the week from. One way to translate placeholders is to mean I would say “all” the word. At the top level, this cron job lists every minute of every hour associated with every day of the seven-month logged business days. Also, for a given interval of zero weeks, Saturday is Saturday and six is Saturday. also (7 can often mean Sunday.)
Pre Let’s say we’ve now slightly modified the cron job mentioned above. We will rewrite * like this:
* * * * Step 6
Remember that 6 is Saturday. That’s why Ville’s schedule is scheduled by the minute every hour, every month, but it only expires on Saturday. Now maybe do the same and change the schedule like this:
43 * to * * * * 6
This schedule is published every Saturday at the forty-third minute. So, just for fun, let’s continue with this example, but let’s look at one more thing:
43 0 4 11 6
Will the audience be able to guess the final program? If you guessed that this time falls on 00:43 on any Saturday in November and the fourth of November, then you are right!
The more tasks you complete, the easier it will be to complete them. Remember that doing it right is very important. Always check with a dedicated cron site like this one.
How To Set Up Cron?
So we’ve discussed in detail what cron does, what function you would consider, and how the format works. silicone is now on its way and we will run a very simple cron job. We ZLet’s plan it so that a file named “test4” is created every few minutes, even if it doesn’t exist. I hope you have or macos Linux that you can take with you.
*nix systems have a nifty organizer for cron operations called crontab.Est probably (tab, short for table). Crontab is an important place to schedule everything, including your cron jobs. We’ll write our schedule into a crontab and watch the miracles happen.
First, open everything terminal up. Navigate yours to a desktop similar to mine:
Note that I just used the return to cd command to do this. Pwd Enter and click Submit. pwd displays the working current directory. Copy the path. We will use it soon.
Next, install crontab -l. This command will display a nice list of cron jobs that are definitely scheduled on your computer. Chances are some, not all, are scheduled, in which case nothing will be displayed.
Then type crontab -e. Will it be open, reads cron. FYI this probably works in open terms edtorus vim. Now, they can be quite esoteric for the real Unknown. The first type is I. Puts this Vim in insert mode so you can type something.
Now that the kitchen table is open and ready to be configured, enter the following command:
* 4 * . * * Click your /desktop/path/
After entering text, hold down the Shift key and press enter on your keyboard. Then highlight wq and press Enter. Vim file in .circle format
Back to cron, we tell the https://cronexpert.com to create (or touch) any file with any name, always within one minute. Don’t worry it (no it won’t create it if it just doesn’t exist and can be easily deleted. See below) a reasoner I created:
We are being treated. Now that we’ve exited crontab, repeat the real Crontab -l command. It will show the new cron job we created. You wait a minute, and the created file actually appears on the desktop. Just type ls to confirm.