Home > Operation and Maintenance > Linux Operation and Maintenance > What is the usage of crontab command under linux

What is the usage of crontab command under linux

(*-*)浩
Release: 2022-04-01 19:42:40
Original
14104 people have browsed it

The crontab command is used to set instructions to be executed periodically. It is common in Unix and Linux operating systems. This command can read instructions from the standard input device and store them in the "crontab" file for later reading and execution; the syntax is "crontab option UserName|file".

What is the usage of crontab command under linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

The crontab command is common in Unix and Linux operating systems and is used to set instructions to be executed periodically.

This command reads instructions from the standard input device and stores them in the "crontab" file for later reading and execution. (Recommended learning: Linux video tutorial)

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

1. System execution Work: work that the system performs periodically, such as backing up system data, cleaning cache

2. Work performed by individuals: work that a user has to do regularly, such as checking whether the mail server is available every 10 minutes Xinxin, these tasks can be set by each user.

System scheduled tasks are generally stored in the file /etc/crontab, which contains some system running schedulers. We can view them through commands Take a look at the content inside:

[root@xiaoluo ~]# cat /etc/crontab 
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
Copy after login

The syntax of the crontab command is:

crontab [-e [UserName]|-l [UserName]|-r [UserName]|-v [UserName]|File ]
Copy after login

Note: crontab is used to allow users to It is used to execute programs at fixed times or fixed intervals. In other words, it is similar to the user's schedule. -u user refers to setting the schedule of the specified user. The premise is that you must have its permissions (for example, root) to specify other people's schedules. If -u user is not used, it means setting your own schedule.

Description of each parameter:

  • -e [UserName]: Execute the text editor to set the schedule, the default text editor Yesvi

  • ##-r [UserName]: Delete the current schedule

  • -l [UserName]: List the current schedule Table

  • -v [UserName]: Lists the status of user cron jobs


For more Linux-related technical articles, please visit

Linux Operation and Maintenance Tutorial column to learn!

The above is the detailed content of What is the usage of crontab command under linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template