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

Under Centos, configure crontab to execute tasks regularly.

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

The main content of this article is to explain "Centos by configuring crontab to regularly execute tasks", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Centos through the configuration of crontab to regularly execute tasks" bar!

Under Centos, tasks can be executed regularly by configuring crontab. The executor can be a system command or a script written by oneself, and the user can be assigned to execute it. There are two ways to configure crontab.

Method 1. Use the crontab command, such as adding a new one or editing an existing one, using:

Crontab-e

You can enter the configuration file. At this time, the executor of configuring crontab is the current login user. If the current user is root and needs to be configured for other users, you can use the

Crontab-e-u user name

Or

Su user name

Crontab-e

One disadvantage of this method is that the crontab configured in the current system is not in a configuration file, which makes it difficult for administrators to query how many crontab there are in the system.

Method 2, add it directly in the / etc/crontab file, but it needs to be a root identity. Open the file and you should see a message similar to the following

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

# For details see man 4 crontabs

# 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

To add a new crontab, just add it at the end of the file. Note that you need to specify a user name here; in method 1, it is not required, and if so, it is considered to be part of the command, which may cause crontab execution to fail.

If all the servers are managed by root, it is recommended to add crontab method 2, so that all the scheduled tasks in the system are together and clear at a glance.

At this point, I believe you have a deeper understanding of "Centos through the configuration of crontab to regularly execute tasks", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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