In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the usage of Cron in Unix and Linux operating system". 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 the usage of Cron in Unix and Linux operating system.
/ sbin/service crond start / / start the service
/ sbin/service crond stop / / shut down the service
/ sbin/service crond restart / / restart the service
/ sbin/service crond reload / / reload the configuration
You can start this service automatically when the system starts:
At the end of the script / etc/rc.d/rc.local, add:
/ sbin/service crond start
1. Edit directly with the crontab command
The cron service provides a crontab command to set the cron service. Here are some parameters and instructions for this command:
Crontab-u / / sets a user's cron service. Generally, root users need this parameter when executing this command.
Crontab-l / / lists the details of a user's cron service
Crontab-r / / Delete cron services without users
Crontab-e / / Edit a user's cron service
For example, root looks at its cron settings:
Crontab-u root-l
For example, root wants to delete the cron setting for fred:
Crontab-u fred-r
When editing a cron service, there are some formats and conventions for editing. Enter:
Reference:
Crontab-u root-e
When you enter vi editing mode, the edited content must conform to the following format:
* / 1 * ls > > / tmp/ls.txt
The first part of this format is the setting of time, and the second part is the commands to be executed. if there are too many commands to be executed, you can write these commands into a script, and then call the script directly here. Remember to write the full path of the command when you call it. We have a certain agreement on the setting of time. The first five * signs represent five digits. The range and meaning of the numbers are as follows:
Reference:
Minutes (0-59)
Hour (0-23)
Date (1-31)
Month (1-12)
The week (0-6) / / 0 represents Sunday
In addition to numbers, there are several special symbols, namely "*", "/" and "-", * represents all the numbers in the range of values, "/" represents each, "* / 5" means every five units, "-" represents from a number to a number, "," separate several discrete numbers. Here are a few examples:
Reference:
6: 00 every morning
0 6 * echo "Good morning." > / tmp/test.txt / / Note simple echo, no output can be seen on the screen, because cron email any output to the mailbox of root.
Every two hours
0 * / 2 * echo "Have a break now." > > / tmp/test.txt
Every two hours between 11:00 and 8 a.m., 8 a.m.
0 23-7 echo 8 * echo "Have a good dream:)" > > / tmp/test.txt
11:00 on the 4th of every month and from Monday to Wednesday
0 11 4 * 1-3 command line
January first at four o'clock in the morning
0 4 1 1 * command line
two。 Edit / etc/crontab file to configure cron
The cron service not only reads all the files in / var/spool/cron once per minute, but also reads / etc/crontab once, so we can configure this file to do something with the cron service. Configuration with crontab is for a user, while editing / etc/crontab is a system-specific task. The file format of this file is:
SHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=root / / if there is an error or there is data output The data is emailed to this account HOME=/# run-parts01 * root run-parts / etc/cron.hourly / / once an hour to execute script 02 4 * root run-parts / etc/cron.daily / / in / etc/cron.hourly once a day / script in / etc/cron.daily 22 4 * * 0 root run-parts / etc/cron.weekly / / once a week to execute / etc Script 42 4 1 in / cron.weekly * * root run-parts / etc/cron.monthly / / execute the script in / etc/cron.monthly once a month
The path that the user runs
Note the parameter "run-parts". If you remove this parameter, you can write the name of a script to run instead of the folder name.
Thank you for your reading. the above is the content of "the usage of Cron in Unix and Linux operating system". After the study of this article, I believe you have a deeper understanding of the usage of Cron in Unix and Linux operating system, and the specific use needs to be verified in practice. 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.