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 set up scheduled tasks in CentOS7

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Today, I will talk to you about how to set up scheduled tasks in CentOS7. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

one。 Install the crontabs service and set up Boot:

Yum install crontabs

Systemctl enable crond

Systemctl start crond123

two。 Set up user-defined scheduled tasks:

Vi / etc/crontab

You can see:

# Example of job definition:#.-minute (0-59) # |.-hour (0-23) # | |.-day of month (1-31) # |.-month (1-12) OR jan,feb,mar,apr. # |.-day of week (0-6) (Sunday=0 or 7) OR sun Mon,tue,wed,thu,fri,sat# | # * user-name command to be executed

That is:

Minutes (0-59) hours (0-23), day (1-31), month (11-12) week (0-6 for Sunday) command to be executed by user name 1

Root executes the updatedb command every 30 minutes:

* / 30 * root updatedb1

Restart the system at 5: 00 a. M. every day:

0 5 * root reboot1

Execute the scripts.sh script in the / home/somedir directory every three seconds:

# # For excuting scripts.sh every 3 seconds##on 2014-10-15 seconds##on 1 * / home/somedir/scripts.sh

* / 1 * sleep 3 & & / home/somedir/scripts.sh

* / 1 * sleep 6 & & / home/somedir/scripts.sh

* / 1 * sleep 9 & & / home/somedir/scripts.sh

* / 1 * sleep 12 & & / home/somedir/scripts.sh

* / 1 * sleep 15 & & / home/somedir/scripts.sh

* / 1 * sleep 18 & & / home/somedir/scripts.sh

* / 1 * sleep 21 & & / home/somedir/scripts.sh

* / 1 * sleep 24 & & / home/somedir/scripts.sh

* / 1 * sleep 27 & & / home/somedir/scripts.sh

* / 1 * sleep 30 & & / home/somedir/scripts.sh

* / 1 * sleep 33 & & / home/somedir/scripts.sh

* / 1 * sleep 36 & & / home/somedir/scripts.sh

* / 1 * sleep 39 & & / home/somedir/scripts.sh

* / 1 * sleep 42 & & / home/somedir/scripts.sh

* / 1 * sleep 45 & & / home/somedir/scripts.sh

* / 1 * sleep 48 & & / home/somedir/scripts.sh

* / 1 * sleep 51 & & / home/somedir/scripts.sh

* / 1 * sleep 54 & & / home/somedir/scripts.sh

* / 1 * sleep 57 & & / home/somedir/scripts.sh223456789101112131415161718192021

After reading the above, do you have any further understanding of how to set up scheduled tasks in CentOS7? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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

Servers

Wechat

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

12
Report