In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to realize the application scene and basic use of Crontab in Linux". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to realize the application scenario and basic use of Crontab in Linux".
Linux version: CentOS 6.6
Application scenarios, such as:
① executes a program every minute to check the running status of the system.
② needs to do statistics on the business data of the past day in the early hours of every morning.
③ needs to back up log files every week.
④ backs up the database every month.
Crontab is a tool for setting periodic execution. The task that is executed periodically is called Cron Job, and the periodic execution list is called Cron Table.
[check crontab service]
① checks if the Crontab tool is installed:
The code is as follows:
Crontab-l
② checks whether the crontab service is started:
The code is as follows:
Service crond status
If the cron service is not installed, you can install the cron service with the following command:
The code is as follows:
Yum install vixie-cron
Yum install crontabs
Example 1. Prints the current time to a log file every minute
The code is as follows:
Corntab-e
Press O and enter:
The code is as follows:
* / 1 * date > > / tmp/log.txt
Press Esc and enter: wq! Save.
Reuse
The code is as follows:
Crontab-l
View scheduled tasks:
View the current time:
The code is as follows:
Date
View / tmp/log.txt
The code is as follows:
Tail-f / tmp/log.txt
Tail-f: keep displaying the last few lines of a file
Tail-3: displays the last three lines of a file
Thank you for your reading, the above is the content of "how to realize the application scenario and basic use of Crontab in Linux". After the study of this article, I believe you have a deeper understanding of how to realize the application scenario and basic use of Crontab in Linux. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.