Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to set up scheduled tasks in CentOS7

Shulou Source: shulou.com Published: 2022-06-01 20:49:35 10月06日 Update

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.

Tags: Tasks content settings commands users hours weeks more user names directories knowledge articles systems scripts industries information information channels channels enter one support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno NVidia MariaDB vpn Shulou Information