In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to use the crond command in Linux. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
1. Work performed by the system: work to be performed periodically by the system, such as backing up system data and cleaning up cache
2. Work performed by an individual: work that a user needs to do on a regular basis, such as checking the mail server every 10 minutes for new messages. These tasks can be set by each user.
Crontab is a scheduled task trigger under UNIX system, and the permissions of its users are recorded in the following two files:
Meaning of document
/ etc/cron.deny users listed in this file are not allowed to use the Crontab command
/ etc/cron.allow users listed in this file are allowed to use the Crontab command
/ var/spool/cron/ is the crontab file for all users
/ var/spool/cron/crontabs / var/spool/cron/crontabs
The format of the Crontab command is: crontab-l |-r |-e |-I [username]. The meaning of the parameter is shown in Table 1:
Example of the meaning of parameter name www.britepic.org
-l displays the contents of the user's Crontab file crontabl-l
-I prompt crontabl-ri before deleting the user's Crontab file
-r Delete the user's Crontab file crontabl-r from the Crontab directory
-e Editing the user's Crontab file crontabl-e
The Crontab file created by the user is stored in / var/spool/cron, and its file name is the same as the user name.
Its format is divided into six segments, the first five paragraphs are the time setting paragraph, and the sixth paragraph is the command section to be executed.
The format is as follows:
The meaning of the time period is shown in Table 2:
Value range of paragraph meaning
* paragraph represents minutes 0Mui 59
The second paragraph represents the hour 0Mui 23.
The third paragraph represents date 1Mui 31
The fourth paragraph represents the first month of the month.
The fifth paragraph represents the day of the week, and 0 represents Sunday 0mur6.
Example: if the content of the user's Crontab file is: 29 19 * echo its dinner time, the system says' its dinner time''at 19:29 every day
Example (the whole process of creating a cron, with the current time entered in the test.txt every minute):
1. Log in to the linux system as an ordinary user (I use CentOS4.1)
2. $crontab-e
Note: the default editor of the system is VIM. If not, please add the following shell:
$EDITOR=vi
$export EDITOR
3. Enter "* / 1 * date > > $HOME/test.txt", save and exit VIM
4. $su root
5. $cd / etc/init.d
6.. / crond restart
Let's look at a few specific examples:
● 0 * / 2 * / sbin/service httpd restart means to restart apache every two hours
● 50 7 * / sbin/service sshd start means to start the ssh service at 7:50 every day
● 50 22 * / sbin/service sshd stop means to shut down the ssh service at 22:50 every day
● 01 15 * * fsck / home check / home disk on the 1st and 15th of each month
● 1 * / home/bruce/backup hourly sub-execution / home/bruce/backup this file
● 00 03 * * 1-5 find / home "* .xxx"-mtime 4-exec rm {}\; from Monday to Friday at 3 o'clock in the directory / home, look for the file named * .xxx and delete the file from 4 days ago.
● 30 6 * / 10 * * ls means to execute the ls command once at 6:30 on the 1st, 11th, 21st and 31st of each month.
The above is how to use the crond command in Linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are 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.
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.