The difference between crontab-e and direct editing/etc/crontab!

Source: Internet
Author: User

Writing a scheduled task is like CRONTAB-E, but what's the difference between this and direct Vim/etc/crontab? Why did you finish the planning task,/etc/crontab?

Method 1: Use the command crontab-e and edit the timed script directly.

After this execution, the user-defined, will be written to the/var/spool/cron directory, generate a file with the user name consistent with the file content is our editor's timed script.

[Email protected] ~]# crontab-l

0 */1 * * */root/mailjiankong.sh

*/5 * * * */root/2.sh

0 * * * */root/3.sh

0 * * */root/4.sh

0 */1 * * */usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1

[Email protected] ~]#

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Method 2:

Edit the timed script using the command vi/etc/crontab.

[Email protected] ~]# Cat/etc/crontab

Shell=/bin/bash

Path=/sbin:/bin:/usr/sbin:/usr/bin

Mailto=root

home=/

# for details see Mans 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

[Email protected] ~]#

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Approximate differences:

1, Crontab will be a grammar check, Vi/vim will not.

2, CRONTAB-E is the user level, and Vim/etc/crontab is the system level.

3, CRONTAB-E is a user's cycle planning task;/etc/crontab is the periodic task of the system.

4, no matter with crontab-e or change/etc/crontab do not need to restart Crond service.

Recommendation: Crontab generally enough to meet the needs, but also check the syntax, compare recommended use!

This article from "Ningzhiyuan @it share" blog, reproduced please contact the author!

The difference between crontab-e and direct editing/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.