欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

淺談Linux配置定時(shí),使用crontab -e與直接編輯/etc/crontab的區(qū)別

 更新時(shí)間:2016年11月30日 10:17:02   投稿:jingxian  
下面小編就為大家?guī)硪黄獪\談Linux配置定時(shí),使用crontab -e與直接編輯/etc/crontab的區(qū)別。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

Linux配置定時(shí)任務(wù),大家都知道使用crontab這個系統(tǒng)功能,但有時(shí)候我們需要區(qū)分用戶執(zhí)行,下面就直接說一下2種方法的區(qū)別:

方法1:

使用命令 crontab -e 然后直接編輯定時(shí)腳本。

這樣執(zhí)行以后,屬于用戶自定義的,會被寫到 /var/spool/cron 目錄下,生成一個和用戶名一致的文件,文件內(nèi)容就是我們編輯的定時(shí)腳本。

如:

[root@localhost cron.d]# cd /var/spool/cron
[root@localhost cron]# ll
總用量 4
-rw-------. 1 root root 52 12月 9 10:58 root
[root@localhost cron]# pwd
/var/spool/cron
[root@localhost cron]# cat root 
30 03 * * * /root/automysqlbackup.sh

方法2:

使用命令 vi /etc/crontab 編輯定時(shí)腳本。

如:

[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 ~]# 

(系統(tǒng)級的)做系統(tǒng)級配置我們會直接配置 /etc/crontab

(用戶級的)一般還是建議大家使用 crontab -e ,這樣系統(tǒng)也會幫著檢查我們配置的腳本語法。

以上這篇淺談Linux配置定時(shí),使用crontab -e與直接編輯/etc/crontab的區(qū)別就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論