Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction and examples of Linux timing tasks

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "introduction and examples of Linux timing tasks". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the introduction and examples of Linux timing tasks.

Catalogue

0x01 introduction

Examples of 0x02 practice

0x01 introduction

In Linux, there are several software that can be used to do timing tasks. We only talk about crontab based on cron services.

Cron is a daemon that executes scheduled tasks, and specific content can be found under etc.

There are two kinds of crontab timing tasks: those run automatically by the system and those operated by the administrator.

The automatic operation of the system is mainly the work to be performed periodically by the system, such as writing cached data to the hard disk, log cleaning and other tasks, which are configured in / etc/crontab

Then let's explain what it represents.

First, minute (0-59) second, hour (0-23) third, day of month (1-31) fourth, month (1-12) fifth, day of week (0-6) (Sunday=0 or 7)

Then there are a few special characters that need to be clarified

* each meaning-continuous time, [1-5], discontiguous time, 1pence2pence3pence4pence5

Then the combination of the above two points can show a lot of meaning.

* execute 1-5 minutes per minute * 1-5 minutes per hour 2 minutes 3 minutes 4 minutes per hour 2, 3 minutes 4 minutes per minute

Note: crontab is only supported up to every minute

We will not talk about the specific implementation examples, which will be illustrated later.

Administrator operation, the work that users have to perform on a regular basis, such as user data backup, regular email reminders, etc.

There are not many common parameters of crontab, so you can check it by yourself.

Examples of 0x02 practice

Let's make sure that the scheduled task is started before we do anything else.

Then we use the-e parameter to enter the edit

After saving, use the-l parameter to view

Next, let's write a task that synchronizes the system time every 5 minutes.

Let's make sure that we can synchronize the time normally.

There is no problem with synchronization time, but there will be output every time, which may become system garbage, so we need to deal with it when writing scheduled tasks.

So what if we want to back up a file regularly, if we want to back up the hosts file at zero every day?

We use a script file to do the operation

Add it to the scheduled task after making sure there is no problem.

At this point, I believe you have a deeper understanding of the "introduction and examples of Linux timing tasks". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report