In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the timed task crond in Linux, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Crontab is a daemon used under linux to periodically perform certain tasks or wait for certain events to be handled. Similar to the scheduled tasks under windows, this service tool is installed by default when the operating system is installed.
Linux task scheduling work is mainly divided into the following two categories
1. Work performed by the system: work to be performed periodically by the system, such as backing up system data, cleaning cache 2, work performed by an individual: work that a user needs to do on a regular basis, such as checking the mail server for new messages every 10 minutes, these tasks can be set by each user.
The meaning of each field is as follows: the minute of each hour, the number of months, the number of weeks, the number of minute hour day month week, the minute of each hour, the minute of every day, the hour of every day, the day of every month, the day of each month, the day of the year, the month of the year, the day of the week, the day
For programmers, the most important thing is to use examples, through which you can clearly understand how to use scheduled tasks.
Note: there is only an absolute path in the crontab command, and there is no relative path, so you need to write an absolute path to execute any command.
1. Execute the ls command at the 5th minute of each hour
5 * ls
2. Execute ls command every 5 minutes
* / 5 * ls
Execute the ls command at 4:30 every day
30 4 * ls
4. Execute the ls command every hour
0 * ls
5. Execute the ls command every day
0 0 * ls
6. Execute ls commands weekly
0 0 * 0 ls
7. Execute ls commands every year
0 0 1 1 * ls
8. Execute the ls command at 7:20 on the 8th of each month
20 7 8 * * ls
9. Execute the ls order at 5:30 on June 28th of each year
30 5 28 6 * ls
10. Execute the ls command at 6:30 every Sunday
30 6 * 0 ls
Note: 0 means Sunday, 1 means Monday, and so on; it can also be expressed in English, sun for Sunday, mon for Monday, etc.
Execute the ls order at 4:30 on the 10th and 20th of each month
30 4 10 ls 20 * *
Note: "," is used to connect multiple discontinuous times.
12. Execute the ls command at the 25th minute of 8: 11 o'clock every day
25 8-11 * ls
Note: "-" is used to connect continuous time
13. Execute the ls command at 5:30 every 10 days of the month
30 5 * / 10 * ls
That is, the ls command is executed at 5:30 on the 1st, 11th, 21st and 31st of each month.
14. Execute all executables in the / etc/cron.daily directory as root at 4:30 every day
30 4 * root run-parts / etc/cron.daily
15. In real use, you usually execute your own executable files
0 * cd / data/sync-data/mdd;/data/GoProjects/bin/go-elastic-index-config=mdd.toml > > mdd.log 2 > & 1
The above command is executed every hour, first enter the specified absolute directory through the cd command, and then use the absolute path to find the executable file for normal execution. The corresponding mdd.toml and mdd.log are in the directory to which cd is located, so it is not necessary to write the whole directory. If you do not use the cd command, the final words are as follows:
0 * / data/GoProjects/bin/go-elastic-index-config=/data/sync-data/mdd/mdd.toml > > / data/sync-data/mdd/mdd.log 2 > & 1
Final order
Crontab-l view scheduled tasks crontab-l-u jp list all scheduled tasks of user jp crontab-e edit scheduled tasks crontab-r delete all scheduled tasks Thank you for reading this article carefully, I hope the article "how to use scheduled tasks crond in Linux" shared by the editor will be helpful to you, at the same time, I hope you will support and follow the industry information channel. More related knowledge is waiting for you 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.