Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the crontab command to set timing and periodically execute tasks in Linux

Shulou Source: shulou.com Published: 2022-06-01 21:07:43 10月01日 Update

In this issue, the editor will bring you about how to use the crontab command to set periodic tasks in Linux. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

Viewing the crontab command from the linux help has the following parameters:

-u username: specifies the user action timer

-e: edit timer (all)

-l: view timer

-r: delete timer (delete a user's crontab file from the / var/spool/cron directory, by default delete the current user's)

-I: delete timer (give confirmation prompt before deletion)

Use scenario 1:

Perform some periodic statistical business operations, such as 0:00 every morning to count the performance of all salespeople and groups the day before, the number of people in each group, tasks, completion, etc., and insert into the database for easy viewing

Use scenario 2:

Instead of manually performing some cyclic operations, such as the announcement of the score line for the girlfriend's postgraduate entrance examination at that time, a timing program was written to monitor the news headlines of the research and recruitment network in real time, and at the same time docked with the SMS verification code platform, as long as the headline of the news headline changed, send a text message to the mobile phone.

(let's take scenario 2 as an example and use the crontab command)

Jianting.php code to execute:

Tags: Tasks commands timers files cycles users text messages systems periodicity content scenarios headlines services monitoring operating systems business news logs permissions headlines Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Linux macOS Shulou Tech Info vpn