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.