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

How to use the crontab command

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

In this article, the editor introduces in detail "how to use the crontab command", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use the crontab command" can help you solve your doubts.

The function of the crontab command is to schedule the execution of some commands at regular intervals. There is a crontab file in the / etc directory, where there are some schedulers that the system is running. Each user can set up his own scheduling crontab.

The crontab file consists of six fields, each of which is divided by spaces, arranged as follows: B.

A MIN HOUR DAY MONTH YEAR COMMAND

B MIN HOUR DAY MONTH DAYOFWEEK COMMAND

C COMMAND HOUR DAY MONTH DAYOFWEEK

D COMMAND YEAR MONTH DAY HOUR MIN

Basic format of crontab:

F1 f2 f3 f4 f5 command

Time-sharing, day, month and week order

The first column F1 represents minutes 1: 59: when F1 means to execute every minute; / n means to execute every n minutes; for aMub, it means to execute from the a minute to the b minute; It means that the a, b and c minutes will be executed.

The second column f2 represents the hour 0: 23 (0 means early morning): when f2 means to execute every hour; / n means to execute once per n decimal; for a Mub means the period from the a hour to the b hour. It means that the a, b and c hours will be executed.

The third column f3 represents day 1: 31: the meaning is shown above, and so on

The fourth column f4 represents the month 1-12: the meaning is shown above, and so on

The fifth column f5 represents Monday 06th (0 for Sunday): the meaning is shown above, and so on

The sixth column command represents the command to be run

Replace it with your own content here.

Let's give an example to illustrate the meaning of the crontab format:

30 20 * / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted at 20:30 every night.

30 20 * / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted at 20:30 every night.

50-3-1-10-10-22 * * / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted at 5: 50 on the 1st, 10th, and 22nd of each month.

10 1 * * 6 0 / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted at 1: 10 every Saturday and Sunday.

0pr 30 19-23 * / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted every 30 minutes between 19: 00 and 23: 00 every day.

0 23 * * 6 / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted every Saturday at 23: 00.

* * / 1 * / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted every hour.

* 23-7bat 1 * / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted every other hour between 11:00 and 7 a.m.

0 12 1 * mon-wed / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted on the 1st of each month and at 12:00 from Monday to Wednesday.

0 5 1 jan * / usr/local/apache/bin/apachectl restart

The above example shows that apache is restarted at 5: 00 on January 1.

After reading this, the article "how to use crontab commands" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

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

Development

Wechat

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

12
Report