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

CentOS下使用yum命令安裝計(jì)劃任務(wù)程序crontab的方法

 更新時(shí)間:2017年09月05日 11:50:41   作者:微wx笑  
這篇文章主要介紹了CentOS下使用yum命令安裝計(jì)劃任務(wù)程序crontab的相關(guān)資料,需要的朋友可以參考下

 概述

利用“任務(wù)計(jì)劃”,可以將任何腳本、程序或文檔安排在某個(gè)最方便的時(shí)間運(yùn)行。通俗的講就是定時(shí)執(zhí)行某個(gè)腳本、程序。

常見(jiàn)用途

定時(shí)關(guān)機(jī)

定時(shí)檢查更新

定時(shí)對(duì)系統(tǒng)配置、數(shù)據(jù)庫(kù)、日志進(jìn)行備份

定時(shí)清理垃圾文件

檢測(cè)是否已安裝

# crontab
-bash: crontab: command not found

執(zhí)行 crontab 命令如果報(bào) command not found,就表明沒(méi)有安裝.

開(kāi)始安裝

# yum -y install vixie-cron
Loaded plugins: fastestmirror, refresh-packagekit, security
Existing lock /var/run/yum.pid: another copy is running as pid 25960.
Another app is currently holding the yum lock; waiting for it to exit...

可能是系統(tǒng)自動(dòng)升級(jí)正在運(yùn)行,yum在鎖定狀態(tài)中。

可以通過(guò)強(qiáng)制關(guān)掉yum進(jìn)程:

#rm -f /var/run/yum.pid

然后就可以使用yum了。

# yum -y install vixie-cron
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
 * base: mirrors.btte.net
 * extras: mirrors.sina.cn
 * updates: mirrors.sina.cn
base                                         | 3.7 kB  00:00  
extras                                         | 3.4 kB  00:00  
extras/primary_db                                      | 32 kB  00:00  
updates                                         | 3.4 kB  00:00  
updates/primary_db                                      | 1.9 MB  00:07  
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package cronie.x86_64 0:1.4.4-15.el6 will be installed
--> Processing Dependency: dailyjobs for package: cronie-1.4.4-15.el6.x86_64
--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-15.el6.x86_64
--> Running transaction check
---> Package cronie-anacron.x86_64 0:1.4.4-15.el6 will be installed
--> Processing Dependency: crontabs for package: cronie-anacron-1.4.4-15.el6.x86_64
---> Package sendmail.x86_64 0:8.14.4-9.el6 will be installed
--> Processing Dependency: procmail for package: sendmail-8.14.4-9.el6.x86_64
--> Running transaction check
---> Package crontabs.noarch 0:1.10-33.el6 will be installed
---> Package procmail.x86_64 0:3.22-25.1.el6_5.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================================================================
 Package           Arch          Version            Repository        Size
===============================================================================================================================================================================================
Installing:
 cronie           x86_64         1.4.4-15.el6           base         74 k
Installing for dependencies:
 cronie-anacron         x86_64         1.4.4-15.el6           base         31 k
 crontabs           noarch         1.10-33.el6           base         10 k
 procmail           x86_64         3.22-25.1.el6_5.1          base         162 k
 sendmail           x86_64         8.14.4-9.el6           base         716 k
Transaction Summary
===============================================================================================================================================================================================
Install  5 Package(s)
Total download size: 994 k
Installed size: 2.1 M
Downloading Packages:
(1/5): cronie-1.4.4-15.el6.x86_64.rpm                                 | 74 kB  00:00  
(2/5): cronie-anacron-1.4.4-15.el6.x86_64.rpm                               | 31 kB  00:00  
(3/5): crontabs-1.10-33.el6.noarch.rpm                                 | 10 kB  00:00  
(4/5): procmail-3.22-25.1.el6_5.1.x86_64.rpm                               | 162 kB  00:00  
(5/5): sendmail-8.14.4-9.el6.x86_64.rpm                                 | 716 kB  00:00  
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                       1.3 MB/s | 994 kB  00:00  
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing : procmail-3.22-25.1.el6_5.1.x86_64                                   1/5 
 Installing : sendmail-8.14.4-9.el6.x86_64                                    2/5 
 Installing : cronie-1.4.4-15.el6.x86_64                                     3/5 
 Installing : crontabs-1.10-33.el6.noarch                                     4/5 
 Installing : cronie-anacron-1.4.4-15.el6.x86_64                                   5/5 
ERROR:dbus.proxies:Introspect error on :1.2513:/org/freedesktop/PackageKit: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
Unable to send message to PackageKit
 Verifying : crontabs-1.10-33.el6.noarch                                     1/5 
 Verifying : cronie-anacron-1.4.4-15.el6.x86_64                                   2/5 
 Verifying : sendmail-8.14.4-9.el6.x86_64                                    3/5 
 Verifying : cronie-1.4.4-15.el6.x86_64                                     4/5 
 Verifying : procmail-3.22-25.1.el6_5.1.x86_64                                   5/5 
Installed:
 cronie.x86_64 0:1.4.4
15.el6              
Dependency Installed:
 cronie-anacron.x86_64 0:1.4.4-15.el6    crontabs.noarch 0:1.10-33.el6    procmail.x86_64 0:3.22-25.1.el6_5.1    sendmail.x86_64 0:8.14.4-9.el6    
Complete!

查看命令幫助

crontab 并不支持-h或–help之類(lèi)的選項(xiàng),不過(guò)還是可以通過(guò)它查看命令幫助

# crontab -h
crontab:無(wú)效選項(xiàng) -- h
crontab: usage error: unrecognized option
usage: crontab [-u user] file
 crontab [-u user] [ -e | -l | -r ]
  (default operation is replace, per 1003.2)
 -e (edit user's crontab)
 -l (list user's crontab)
 -r (delete user's crontab)
 -i (prompt before deleting user's crontab)
 -s (selinux context)

也可以使用 info crontab 命令查看詳細(xì)的幫助信息。

cron服務(wù)提供crontab命令來(lái)設(shè)定cron服務(wù)的,以下是這個(gè)命令的一些參數(shù)與說(shuō)明:

  crontab -u //設(shè)定某個(gè)用戶(hù)的cron服務(wù),一般root用戶(hù)在執(zhí)行這個(gè)命令的時(shí)候需要此參數(shù)

  crontab -l //列出某個(gè)用戶(hù)cron服務(wù)的詳細(xì)內(nèi)容

  crontab -r //刪除沒(méi)個(gè)用戶(hù)的cron服務(wù)

  crontab -e //編輯某個(gè)用戶(hù)的cron服務(wù)

  比如說(shuō)root查看自己的cron設(shè)置:crontab -u root -l

  再例如,root想刪除fred的cron設(shè)置:crontab -u fred -r

  在編輯cron服務(wù)時(shí),編輯的內(nèi)容有一些格式和約定,輸入:crontab -u root -e

  進(jìn)入vi編輯模式,編輯的內(nèi)容一定要符合下面的格式:/1 * * * ls >> /tmp/ls.txt

服務(wù)狀態(tài)控制

/sbin/service crond start //啟動(dòng)服務(wù) 
/sbin/service crond stop //關(guān)閉服務(wù) 
/sbin/service crond restart //重啟服務(wù) 
/sbin/service crond reload //重新載入配置 
/sbin/service crond status //查看狀態(tài)

或者使用

# service crond start 
# service crond stop 
# service crond restart 
# service crond reload 
# service crond status

開(kāi)機(jī)啟動(dòng)

你也可以將這個(gè)服務(wù)在系統(tǒng)啟動(dòng)的時(shí)候自動(dòng)啟動(dòng):

在/etc/rc.d/rc.local這個(gè)腳本的末尾加上:

/sbin/service crond start

現(xiàn)在Cron這個(gè)服務(wù)已經(jīng)在進(jìn)程里面了,我們就可以用這個(gè)服務(wù)了。

總結(jié)

以上所述是小編給大家介紹的CentOS下使用yum命令安裝計(jì)劃任務(wù)程序crontab,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論