During Linux configuration, use crontab and configure crontab in linux.

Source: Internet
Author: User

During Linux configuration, use crontab and configure crontab in linux.


In Linux, we all know how to use the crontab system function to configure scheduled tasks. However, sometimes we need to differentiate user execution. The following describes the differences between the two methods:

Method 1:

Run the crontab-e command to directly edit the scheduled script.

After this execution, the User-Defined file will be written to the/var/spool/cron directory to generate a file consistent with the user name. The file content is the scheduled script We edited.

For example:

[Root @ localhost cron. d] # cd/var/spool/cron [root @ localhost cron] # ll total usage 4-rw -------. 1 root 52 December 9 10:58 root [root @ localhost cron] # pwd/var/spool/cron [root @ localhost cron] # cat root 30 03 ***/root/automysqlbackup. sh

Method 2:

Run the command vi/etc/crontab to edit the scheduled script.

For example:

[root@localhost ~]# cat /etc/crontab                                                                                                                                                                      SHELL=/bin/bash                                                                                                                                                                                           PATH=/sbin:/bin:/usr/sbin:/usr/bin                                                                                                                                                                        MAILTO=root                                                                                                                                                                                               HOME=/                                                                                                                                                                                                                                                                                                                                                                                                              # run-parts                                                                                                                                                                                               30 * * * * root /usr/sbin/ntpdate 210.72.145.44                                                                                                                                                           #30 8 * * * root /usr/sbin/ntpdate 132.228.90.101                                                                                                                                                         01 * * * * root run-parts /etc/cron.hourly                                                                                                                                                                02 4 * * * root run-parts /etc/cron.daily                                                                                                                                                                 22 4 * * 0 root run-parts /etc/cron.weekly                                                                                                                                                                42 4 1 * * root run-parts /etc/cron.monthly                                                                                                                                                               */1 * * * * root run-parts /opt/openoffice.org3/program/start.sh                                                                                                                                          ############################################                                                                                                                                                                                                                                                                                                                                                                        30 4 * * * root /usr/bin/rsync -vzrtopg --progress --delete root@192.168.231.35::resource /hyy/bak/resource 30 4 * * * root /usr/bin/rsync -vzrtopg --progress --delete root@192.168.231.35::log /hyy/bak/log############################################[root@localhost ~]# 


For system-level configuration, We will directly Configure/etc/crontab.

Generally, we recommend that you use crontab-e to check the script syntax we configured.




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.