Linux Add timed tasks, the difference between the CRONTAB-E command and the direct edit/etc/crontab

Source: Internet
Author: User

1. Edit the Scheduled task list using the CRONTAB-E command

The list of scheduled tasks edited with this command is user-level, and a file with the same user name is generated in the/var/spool/cron directory after the first edit, and the file content is our scheduled task list. If there is no scheduled task, this file is an empty file.

The crontab command also has some other options

-U #指定哪个用户的cron服务, which is typically required when the root user executes this command

-l #列出用户的定时任务列表, default current user

-R #删除用户的定时任务列表, default current user

-e #编辑用户的定时任务列表, default current user

Example: List of cron services for xiaoming users

Crontab-u xiaoming-l

2. Edit the/etc/crontab file directly with the following command:

Vim/etc/crontab

We will see the contents of the file as follows:

shell=/bin/Bashpath=/sbin:/bin:/usr/sbin:/usr/Binmailto=Roothome=/# for details seeMans 4crontabs# Example of Job definition:#.----------------Minute (0- -)# | .-------------Hour (0- at)# |  | .----------Day of Month (1- to)# |  |  | .-------Month (1- A) OR jan,feb,mar,apr ... #|  |  |  | .----Day of Week (0-6) (sunday=0Or7) OR sun,mon,tue,wed,thu,fri,sat#|  |  |  | |# * * * * * * user-name command to be executed

The scheduled tasks for this configuration are at the system level.

3. Recommendations

It is generally recommended that you use CRONTAB-E so that the system will also help check the scripting syntax of our configuration.

Linux Add timed tasks, the difference between the CRONTAB-E command and the direct edit/etc/crontab

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.