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 use crontab

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

Share

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

This article mainly introduces the use of crontab, has a certain reference value, friends in need can refer to. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

Crontab commands are common in Unix and Linux operating systems and are used to set instructions that are executed periodically.

This command reads instructions from a standard input device and stores them in a "crontab" file for later reading and execution.

In Linux system, Linux task scheduling is mainly divided into the following two categories:

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 for new messages every 10 minutes, which can be set by each user.

The tasks scheduled by the system are generally stored in the / etc/crontab file, in which there are some schedulers running by the system. We can take a look at the contents through the command:

[root@xiaoluo ~] # cat / etc/crontab SHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=rootHOME=/# 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

The syntax of the crontab command is:

Crontab [- e [UserName] |-l [UserName] |-r [UserName] |-v [UserName] | File]

Note: crontab is used to allow users to execute programs at fixed times or at regular intervals, in other words, similar to the user's schedule. -u user means to set a schedule that specifies user, which requires that you have permission (such as root) to specify someone else's schedule. If you don't use-u user, it means to set your own schedule.

Description of each parameter:

-e [UserName]: execute a text editor to set the schedule, and the internal text editor is vi

-r [UserName]: delete the current schedule

-l [UserName]: list the current schedule

-v [UserName]: lists the status of the user's cron job

Thank you for reading this article carefully. I hope it will be helpful for everyone to share the usage of crontab. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you 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