软件安装 RPM SRPM YUM

RPM介绍

 

 

 

 

 

 

 

 

RPM是已经编译好的软件安装库。编译是有相应环境相适应的,包括系统,版本等相关信息都要跟编译版本一致才行,否则肯定会出现安装不成功的情况,强制安装的话,也会出现各种各样的问题。

在这种情况下,就出现了SRPM的格式,带源码的安装库文件。

 

 

 

RPM和SRPM的相关区别,如下图

 

 

 

 

 

YUM原理图

 

 

 

 

 rpm使用详解

 

强制安装

 

 

 

 

 

 

 

 同理,如果要安装U盘中的软件,也需要如此来进行操作

 

RPM 升级与更新

 

 

 

 RPM查询软件是否安装

[root@localhost ~]# rpm -q lograotate
未安装软件包 lograotate 
[root@localhost ~]# rpm -q logrotate
logrotate-3.8.6-17.el7.x86_64
[root@localhost ~]# rpm -q logrotating
未安装软件包 logrotating 
[root@localhost ~]# rpm -ql logrotate
/etc/cron.daily/logrotate
/etc/logrotate.conf
/etc/logrotate.d
/etc/rwtab.d/logrotate
/usr/sbin/logrotate
/usr/share/doc/logrotate-3.8.6
/usr/share/doc/logrotate-3.8.6/CHANGES
/usr/share/doc/logrotate-3.8.6/COPYING
/usr/share/man/man5/logrotate.conf.5.gz
/usr/share/man/man8/logrotate.8.gz
/var/lib/logrotate
/var/lib/logrotate/logrotate.status
[root@localhost ~]# rpm -q perl     #不需要将全称都输入。我一开始查询的时候一大堆软件,而且名称很长,这样看,只需要将软件名进行查询就可以查询到软件的相关信息
perl-5.16.3-293.el7.x86_64

[root@localhost ~]# rpm -qi perl

 


Name : perl #软件名称
Epoch : 4  
Version : 5.16.3  #软件的版本
Release : 293.el7  #释出的版本
Architecture: x86_64  #编译针对的系统信息
Install Date: 2019年08月19日 星期一 11时01分30秒  #安装日期
Group : Development/Languages  #软件是放在哪一个群组中
Size : 23552029  #大小
License : (GPL+ or Artistic) and (GPLv2+ or Artistic) and Copyright Only and MIT and Public Domain and UCD  #授权方式
Signature : RSA/SHA256, 2018年11月12日 星期一 22时43分53秒, Key ID 24c6a8a7f4a80eb5  
Source RPM : perl-5.16.3-293.el7.src.rpm  #SRPM的文档名 就是这个source源码
Build Date : 2018年10月31日 星期三 03时03分24秒  #打包时间
Build Host : x86-01.bsys.centos.org  #打包主机
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.perl.org/
Summary : Practical Extraction and Report Language
Description :  #详细信息
Perl is a high-level programming language with roots in C, sed, awk and shell
scripting. Perl is good at handling processes and files, and is especially
good at handling text. Perl's hallmarks are practicality and efficiency.
While it is used to do a lot of different things, Perl's most common
applications are system administration utilities and web programming. A large
proportion of the CGI scripts on the web are written in Perl. You need the
perl package installed on your system so that your system can handle Perl
scripts.

Install this package if you want to program in Perl or enable your system to
handle Perl scripts.

注意,查询某个软件是否安装,只需要输入软件名就可以,因为它已在 /var/lib/rpm数据库中存在。但是如果要查询RPM文件,就必须输入全名才能查得到。这点要注意

 

 

 

[root@localhost ~]# rpm -qa | grep ^c | wc-l
bash: wc-l: 未找到命令...
[root@localhost ~]# rpm -qa | grep ^c | wc-1
bash: wc-1: 未找到命令...
[root@localhost ~]# rpm -qa | grep ^c | wc -l
84
[root@localhost ~]# rpm -qf /etc/crontab
crontabs-1.11-6.20121102git.el7.noarch

 

 

RPM 验证与数字签名

详解

 

内容解析:

 

 

 

 

rpm数字签名

[root@localhost ~]# rpm -V logrotate
[root@localhost ~]# locate GPG-KEY
/etc/pki/fwupd/GPG-KEY-Hughski-Limited
/etc/pki/fwupd/GPG-KEY-Linux-Foundation-Firmware
/etc/pki/fwupd/GPG-KEY-Linux-Vendor-Firmware-Service
/etc/pki/fwupd-metadata/GPG-KEY-Linux-Foundation-Metadata
/etc/pki/fwupd-metadata/GPG-KEY-Linux-Vendor-Firmware-Service
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Testing-7
[root@localhost ~]# rpm -qa | grep pubkey
gpg-pubkey-f4a80eb5-53a7ff4b
[root@localhost ~]# rpm -qi gpg-pubkey-f4a80eb5-53a7ff4b
Name        : gpg-pubkey
Version     : f4a80eb5
Release     : 53a7ff4b
Architecture: (none)
Install Date: 2019年08月29日 星期四 17时23分48秒
Group       : Public Keys
Size        : 0
License     : pubkey
Signature   : (none)
Source RPM  : (none)
Build Date  : 2014年06月23日 星期一 18时19分55秒
Build Host  : localhost
Relocations : (not relocatable)
Packager    : CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>
Summary     : gpg(CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>)
Description :
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: rpm-4.11.3 (NSS-3)

mQINBFOn/0sBEADLDyZ+DQHkcTHDQSE0a0B2iYAEXwpPvs67cJ4tmhe/iMOyVMh9
Yw/vBIF8scm6T/vPN5fopsKiW9UsAhGKg0epC6y5ed+NAUHTEa6pSOdo7CyFDwtn
4HF61Esyb4gzPT6QiSr0zvdTtgYBRZjAEPFVu3Dio0oZ5UQZ7fzdZfeixMQ8VMTQ
4y4x5vik9B+cqmGiq9AW71ixlDYVWasgR093fXiD9NLT4DTtK+KLGYNjJ8eMRqfZ
Ws7g7C+9aEGHfsGZ/SxLOumx/GfiTloal0dnq8TC7XQ/JuNdB9qjoXzRF+faDUsj
WuvNSQEqUXW1dzJjBvroEvgTdfCJfRpIgOrc256qvDMp1SxchMFltPlo5mbSMKu1
x1p4UkAzx543meMlRXOgx2/hnBm6H6L0FsSyDS6P224yF+30eeODD4Ju4BCyQ0jO
IpUxmUnApo/m0eRelI6TRl7jK6aGqSYUNhFBuFxSPKgKYBpFhVzRM63Jsvib82rY
438q3sIOUdxZY6pvMOWRkdUVoz7WBExTdx5NtGX4kdW5QtcQHM+2kht6sBnJsvcB
JYcYIwAUeA5vdRfwLKuZn6SgAUKdgeOtuf+cPR3/E68LZr784SlokiHLtQkfk98j
NXm6fJjXwJvwiM2IiFyg8aUwEEDX5U+QOCA0wYrgUQ/h8iathvBJKSc9jQARAQAB
tEJDZW50T1MtNyBLZXkgKENlbnRPUyA3IE9mZmljaWFsIFNpZ25pbmcgS2V5KSA8
c2VjdXJpdHlAY2VudG9zLm9yZz6JAjUEEwECAB8FAlOn/0sCGwMGCwkIBwMCBBUC
CAMDFgIBAh4BAheAAAoJECTGqKf0qA61TN0P/2730Th8cM+d1pEON7n0F1YiyxqG
QzwpC2Fhr2UIsXpi/lWTXIG6AlRvrajjFhw9HktYjlF4oMG032SnI0XPdmrN29lL
F+ee1ANdyvtkw4mMu2yQweVxU7Ku4oATPBvWRv+6pCQPTOMe5xPG0ZPjPGNiJ0xw
4Ns+f5Q6Gqm927oHXpylUQEmuHKsCp3dK/kZaxJOXsmq6syY1gbrLj2Anq0iWWP4
Tq8WMktUrTcc+zQ2pFR7ovEihK0Rvhmk6/N4+4JwAGijfhejxwNX8T6PCuYs5Jiv
hQvsI9FdIIlTP4XhFZ4N9ndnEwA4AH7tNBsmB3HEbLqUSmu2Rr8hGiT2Plc4Y9AO
aliW1kOMsZFYrX39krfRk2n2NXvieQJ/lw318gSGR67uckkz2ZekbCEpj/0mnHWD
3R6V7m95R6UYqjcw++Q5CtZ2tzmxomZTf42IGIKBbSVmIS75WY+cBULUx3PcZYHD
ZqAbB0Dl4MbdEH61kOI8EbN/TLl1i077r+9LXR1mOnlC3GLD03+XfY8eEBQf7137
YSMiW5r/5xwQk7xEcKlbZdmUJp3ZDTQBXT06vavvp3jlkqqH9QOE8ViZZ6aKQLqv
pL+4bs52jzuGwTMT7gOR5MzD+vT0fVS7Xm8MjOxvZgbHsAgzyFGlI1ggUQmU7lu3
uPNL0eRx4S1G4Jn5
=OGYX
-----END PGP PUBLIC KEY BLOCK-----

软件卸载

如何安装的则如何卸载

通过rpm -e 命令来卸载软件

 

但是存在软件相依性的问题,所以导致有可能卸载不成功,除非将所有依存软件都卸载才行。

卸载之后,需要重建一下数据库

 

 

 YUM  在线升级机制

 使用YUM就必须要YUM源,目前在国内我们用的一般都是阿里的YUM源

 

 

 

 

 

 

手动修改YUM源

我们一般采用的是阿里云的YUM源。

这就需要更改 /etc/yum.repos.d/CentOS-Base.repo文件

下图是文件介绍

 

采用阿里云的YUM源有两种方式,一种是直接从阿里云上下载repo,然后改名放到 /etc/yum.repos.d 中即可。

一种是直接将阿里云的repo文件代码复制粘贴,记得备份

阿里云repo代码

[root@localhost yum.repos.d]# cat CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

原来的repo代码如下

[root@localhost yum.repos.d]# cat CentOS-Base-backup.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

然后运行yum makecache生成缓存
yum clean all
yum makecache 

这个yum源就可以用了

测试yum源是否工作正常,可以用  yum repolist all命令来测试,如下

C7.0.1406-base/x86_64                                                                                     CentOS-7.0.1406 - Base                                                                                                禁用
C7.0.1406-centosplus/x86_64                                                                               CentOS-7.0.1406 - CentOSPlus                                                                                          禁用
C7.0.1406-extras/x86_64                                                                                   CentOS-7.0.1406 - Extras                                                                                              禁用
C7.0.1406-fasttrack/x86_64                                                                                CentOS-7.0.1406 - Fasttrack                                                                                           禁用
C7.0.1406-updates/x86_64                                                                                  CentOS-7.0.1406 - Updates                                                                                             禁用
C7.1.1503-base/x86_64                                                                                     CentOS-7.1.1503 - Base                                                                                                禁用
C7.1.1503-centosplus/x86_64                                                                               CentOS-7.1.1503 - CentOSPlus                                                                                          禁用
C7.1.1503-extras/x86_64                                                                                   CentOS-7.1.1503 - Extras                                                                                              禁用
C7.1.1503-fasttrack/x86_64                                                                                CentOS-7.1.1503 - Fasttrack                                                                                           禁用
C7.1.1503-updates/x86_64                                                                                  CentOS-7.1.1503 - Updates                                                                                             禁用
C7.2.1511-base/x86_64                                                                                     CentOS-7.2.1511 - Base                                                                                                禁用
C7.2.1511-centosplus/x86_64                                                                               CentOS-7.2.1511 - CentOSPlus                                                                                          禁用
C7.2.1511-extras/x86_64                                                                                   CentOS-7.2.1511 - Extras                                                                                              禁用
C7.2.1511-fasttrack/x86_64                                                                                CentOS-7.2.1511 - Fasttrack                                                                                           禁用
C7.2.1511-updates/x86_64                                                                                  CentOS-7.2.1511 - Updates                                                                                             禁用
C7.3.1611-base/x86_64                                                                                     CentOS-7.3.1611 - Base                                                                                                禁用
C7.3.1611-centosplus/x86_64                                                                               CentOS-7.3.1611 - CentOSPlus                                                                                          禁用
C7.3.1611-extras/x86_64                                                                                   CentOS-7.3.1611 - Extras                                                                                              禁用
C7.3.1611-fasttrack/x86_64                                                                                CentOS-7.3.1611 - Fasttrack                                                                                           禁用
C7.3.1611-updates/x86_64                                                                                  CentOS-7.3.1611 - Updates                                                                                             禁用
C7.4.1708-base/x86_64                                                                                     CentOS-7.4.1708 - Base                                                                                                禁用
C7.4.1708-centosplus/x86_64                                                                               CentOS-7.4.1708 - CentOSPlus                                                                                          禁用
C7.4.1708-extras/x86_64                                                                                   CentOS-7.4.1708 - Extras                                                                                              禁用
C7.4.1708-fasttrack/x86_64                                                                                CentOS-7.4.1708 - Fasttrack                                                                                           禁用
C7.4.1708-updates/x86_64                                                                                  CentOS-7.4.1708 - Updates                                                                                             禁用
C7.5.1804-base/x86_64                                                                                     CentOS-7.5.1804 - Base                                                                                                禁用
C7.5.1804-centosplus/x86_64                                                                               CentOS-7.5.1804 - CentOSPlus                                                                                          禁用
C7.5.1804-extras/x86_64                                                                                   CentOS-7.5.1804 - Extras                                                                                              禁用
C7.5.1804-fasttrack/x86_64                                                                                CentOS-7.5.1804 - Fasttrack                                                                                           禁用
C7.5.1804-updates/x86_64                                                                                  CentOS-7.5.1804 - Updates                                                                                             禁用
base/7/x86_64                                                                                             CentOS-7 - Base                   启用                                                         启用: 10,097
base-debuginfo/x86_64                                                                                     CentOS-7 - Debuginfo                                                                                                  禁用
base-source/7                                                                                             CentOS-7 - Base Sources                                                                                               禁用
c7-media                                                                                                  CentOS-7 - Media                                                                                                      禁用
centosplus/7/x86_64                                                                                       CentOS-7 - Plus                                                                                                       禁用
centosplus-source/7                                                                                       CentOS-7 - Plus Sources                                                                                               禁用
contrib/7/x86_64                                                                                          CentOS-7 - Contrib - mirrors.aliyun.com                                                                               禁用
cr/7/x86_64                                                                                               CentOS-7 - cr                                                                                                         禁用
extras/7/x86_64                                                                                           CentOS-7 - Extras                                                                             启用:    304
extras-source/7                                                                                           CentOS-7 - Extras Sources                                                                                             禁用
fasttrack/7/x86_64                                                                                        CentOS-7 - fasttrack                                                                                                  禁用
updates/7/x86_64                                                                                          CentOS-7 - Updates                                             update也是启用                            启用:    310
updates-source/7                                                                                          CentOS-7 - Updates Sources                                                                 禁用
repolist: 10,711

这就证明可以用了。

 

 

 

 

 yum  群组功能

 

 

 

[root@localhost yum.repos.d]# yum grouplist
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
没有安装组信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
可用的环境分组:
   最小安装
   基础设施服务器
   计算节点
   文件及打印服务器
   基本网页服务器
   虚拟化主机
   带 GUI 的服务器
   GNOME 桌面
   KDE Plasma Workspaces
   开发及生成工作站
可用组:
   传统 UNIX 兼容性
   兼容性程序库
   图形管理工具
   安全性工具
   开发工具
   控制台互联网工具
   智能卡支持
   科学记数法支持
   系统管理
   系统管理工具
完成

 

 

 

 

重点是红框的地方。如果不加,就不会更新。这点很cool。你可以加若干的软件包,然后写入repo中,然后在yum的时候,可以调用不同的软件包进行安装

 

自动升级

yum -y update 命令

如果要设置某个时间段自动更新某个软件的话。如下图

 

 

 

 

关于 cron.d和crontab之间的区别和联系,我查了查资料,如下:

crontab + /etc/cron.d

回到最初的问题,我们需要思路上理清什么时候该用 crontab ?什么时候又该用 /etc/cron.d 呢?

最原始、最粗糙地识别方法——基于执行帐号判断

如果执行帐号是系统帐号,那么就 /etc/cron.d ;如果执行帐号是非系统帐号,那么就 crontab 。

他们俩的格式相同,唯一区别的是,cron.d 在日期后需要加入账号信息。如上例中的 root 这个账户

crontab 的定时任务格式是:

# MIN HOUR DAY MON WEEK CMD
*/15 * * * * /usr/sbin/ntpdate time.nist.gov > /dev/null 2>&1

/etc/cron.d 的任务文件格式与之基本相似,唯独多了 USER 一项:即下例子中的root

# MIN HOUR DAY MON WEEK USER CMD
*/15 * * * * root /usr/sbin/ntpdate time.nist.gov > /dev/null 2>&1

 

 有一篇文章

Linux /etc/cron.d作用(转自 定时任务crontab cron.d)(转载链接如下)

原文链接:http://huangfuligang.blog.51cto.com/9181639/1608549

一、cron.d增加定时任务

当我们要增加全局性的计划任务时,一种方式是直接修改/etc/crontab。但是,一般不建议这样做,/etc/cron.d目录就是为了解决这种问题而创建的。

例如,增加一项定时的备份任务,我们可以这样处理:在/etc/cron.d目录下新建文件backup.sh,内容如下:

    # m h dom mon dow user command

    * 1 * * * root /sbin/mon_zetc_logtar.sh

cron进程执行时,就会自动扫描该目录下的所有文件,按照文件中的时间设定执行后面的命令。

cron执行时,也就是要读取三个地方的配置文件:一是/etc/crontab,二是/etc/cron.d目录下的所有文件,三是每个用户的配置文件

 

二、控制对 cron 的使用

/etc/cron.allow 和 /etc/cron.deny 文件被用来限制对 cron 的使用。这两个使用控制文件的格式都是每行一个用户。两个文件都不允许空格。如果使用控制文件被修改了,cron 守护进程(crond)不必被重启。使用控制文件在每次用户添加或删除一项 cron 任务时都会被读取。

无论使用控制文件中的规定如何,根用户都总是可以使用 cron。

如果 cron.allow 文件存在,只有其中列出的用户才被允许使用 cron,并且 cron.deny 文件会被忽略。

如果 cron.allow 文件不存在,所有在 cron.deny 中列出的用户都被禁止使用 cron

 

三、启动或关闭

由于Cron 是Linux的内置服务,可以用以下的方法启动、关闭这个服务:

/sbin/service crond start //启动服务
/sbin/service crond stop //关闭服务
/sbin/service crond restart //重启服务
/sbin/service crond reload //重新载入配置

 

四、crontab介绍

/etc/crontab 文件中的每一行都代表一项任务,它的格式是:

minute         hour         day         month         dayofweek         command

    minute    — 分钟,从 0 到 59 之间的任何整数

  • hour      — 小时,从 0 到 23 之间的任何整数

  • day       — 日期,从 1 到 31 之间的任何整数(如果指定了月份,必须是该月份的有效日期)

  • month     — 月份,从 1 到 12 之间的任何整数(或使用月份的英文简写如 jan、feb 等等)

  • dayofweek — 星期,从 0 到 7 之间的任何整数,这里的 0 或 7 代表星期日(或使用星期的英文简写如 sun、mon 等等)

  • command — 要执行的命令(命令可以是 ls /proc >> /tmp/proc 之类的命令,也可以是执行你自行编写的脚本的命令。)

在以上任何值中,星号(*)可以用来代表所有有效的值。譬如,月份值中的星号意味着在满足其它制约条件后每月都执行该命令。

整数间的短线(-)指定一个整数范围。譬如,1-4 意味着整数 1、2、3、4。

用逗号(,)隔开的一系列值指定一个列表。譬如,3, 4, 6, 8 标明这四个指定的整数。

正斜线(/)可以用来指定间隔频率。在范围后加上 /<integer> 意味着在范围内可以跳过 integer。譬如,0-59/2可以用来在分钟字段定义每两分钟。间隔频率值还可以和星号一起使用。例如,*/3 的值可以用在月份字段中表示每三个月运行一次任务。

开头为井号(#)的行是注释,不会被处理

 

(系统级的)做系统级配置我们会直接配置 /etc/crontab

(用户级的)一般还是建议大家使用 crontab -e ,这样系统也会帮着检查我们配置的脚本语法。

 

 

操作实例:

 

[root@localhost ~]# yum install  httpd php mariadb-server php-mysql      
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 php-5.4.16-46.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-88.el7.centos 将被 升级
--> 正在处理依赖关系 httpd = 2.4.6-88.el7.centos,它被软件包 httpd-manual-2.4.6-88.el7.centos.noarch 需要
--> 正在处理依赖关系 httpd = 2.4.6-88.el7.centos,它被软件包 1:mod_ssl-2.4.6-88.el7.centos.x86_64 需要
--> 正在处理依赖关系 httpd = 2.4.6-88.el7.centos,它被软件包 httpd-devel-2.4.6-88.el7.centos.x86_64 需要
---> 软件包 httpd.x86_64.0.2.4.6-90.el7.centos 将被 更新
--> 正在处理依赖关系 httpd-tools = 2.4.6-90.el7.centos,它被软件包 httpd-2.4.6-90.el7.centos.x86_64 需要
---> 软件包 mariadb-server.x86_64.1.5.5.60-1.el7_5 将被 升级
---> 软件包 mariadb-server.x86_64.1.5.5.64-1.el7 将被 更新
--> 正在处理依赖关系 mariadb-libs(x86-64) = 1:5.5.64-1.el7,它被软件包 1:mariadb-server-5.5.64-1.el7.x86_64 需要
--> 正在处理依赖关系 mariadb(x86-64) = 1:5.5.64-1.el7,它被软件包 1:mariadb-server-5.5.64-1.el7.x86_64 需要
---> 软件包 php-mysql.x86_64.0.5.4.16-46.el7 将被 安装
--> 正在检查事务
---> 软件包 httpd-devel.x86_64.0.2.4.6-88.el7.centos 将被 升级
---> 软件包 httpd-devel.x86_64.0.2.4.6-90.el7.centos 将被 更新
---> 软件包 httpd-manual.noarch.0.2.4.6-88.el7.centos 将被 升级
---> 软件包 httpd-manual.noarch.0.2.4.6-90.el7.centos 将被 更新
---> 软件包 httpd-tools.x86_64.0.2.4.6-88.el7.centos 将被 升级
---> 软件包 httpd-tools.x86_64.0.2.4.6-90.el7.centos 将被 更新
---> 软件包 mariadb.x86_64.1.5.5.60-1.el7_5 将被 升级
---> 软件包 mariadb.x86_64.1.5.5.64-1.el7 将被 更新
---> 软件包 mariadb-libs.x86_64.1.5.5.60-1.el7_5 将被 升级
--> 正在处理依赖关系 mariadb-libs(x86-64) = 1:5.5.60-1.el7_5,它被软件包 1:mariadb-devel-5.5.60-1.el7_5.x86_64 需要
---> 软件包 mariadb-libs.x86_64.1.5.5.64-1.el7 将被 更新
---> 软件包 mod_ssl.x86_64.1.2.4.6-88.el7.centos 将被 升级
---> 软件包 mod_ssl.x86_64.1.2.4.6-90.el7.centos 将被 更新
--> 正在检查事务
---> 软件包 mariadb-devel.x86_64.1.5.5.60-1.el7_5 将被 升级
---> 软件包 mariadb-devel.x86_64.1.5.5.64-1.el7 将被 更新
--> 解决依赖关系完成

依赖关系解决

============================================================================================================================================================================================================================================
 Package                                                     架构                                                版本                                                               源                                                 大小
============================================================================================================================================================================================================================================
正在安装:
 php-mysql                                                   x86_64                                              5.4.16-46.el7                                                      base                                              101 k
正在更新:
 httpd                                                       x86_64                                              2.4.6-90.el7.centos                                                base                                              2.7 M
 mariadb-server                                              x86_64                                              1:5.5.64-1.el7                                                     base                                               11 M
为依赖而更新:
 httpd-devel                                                 x86_64                                              2.4.6-90.el7.centos                                                base                                              197 k
 httpd-manual                                                noarch                                              2.4.6-90.el7.centos                                                base                                              1.3 M
 httpd-tools                                                 x86_64                                              2.4.6-90.el7.centos                                                base                                               91 k
 mariadb                                                     x86_64                                              1:5.5.64-1.el7                                                     base                                              8.7 M
 mariadb-devel                                               x86_64                                              1:5.5.64-1.el7                                                     base                                              755 k
 mariadb-libs                                                x86_64                                              1:5.5.64-1.el7                                                     base                                              759 k
 mod_ssl                                                     x86_64                                              1:2.4.6-90.el7.centos                                              base                                              112 k

事务概要
============================================================================================================================================================================================================================================
安装  1 软件包
升级  2 软件包 (+7 依赖软件包)

总下载量:26 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
(1/10): httpd-tools-2.4.6-90.el7.centos.x86_64.rpm                                                                                                                                                                   |  91 kB  00:00:00     
(2/10): httpd-devel-2.4.6-90.el7.centos.x86_64.rpm                                                                                                                                                                   | 197 kB  00:00:00     
(3/10): mariadb-devel-5.5.64-1.el7.x86_64.rpm                                                                                                                                                                        | 755 kB  00:00:00     
(4/10): httpd-manual-2.4.6-90.el7.centos.noarch.rpm                                                                                                                                                                  | 1.3 MB  00:00:01     
(5/10): mod_ssl-2.4.6-90.el7.centos.x86_64.rpm                                                                                                                                                                       | 112 kB  00:00:00     
(6/10): mariadb-libs-5.5.64-1.el7.x86_64.rpm                                                                                                                                                                         | 759 kB  00:00:00     
(7/10): php-mysql-5.4.16-46.el7.x86_64.rpm                                                                                                                                                                           | 101 kB  00:00:00     
(8/10): httpd-2.4.6-90.el7.centos.x86_64.rpm                                                                                                                                                                         | 2.7 MB  00:00:01     
(9/10): mariadb-5.5.64-1.el7.x86_64.rpm                                                                                                                                                                              | 8.7 MB  00:00:03     
(10/10): mariadb-server-5.5.64-1.el7.x86_64.rpm                                                                                                                                                                      |  11 MB  00:00:12     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                                                                        1.9 MB/s |  26 MB  00:00:13     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : 1:mariadb-libs-5.5.64-1.el7.x86_64                                                                                                                                                                                     1/19 
  正在更新    : 1:mariadb-5.5.64-1.el7.x86_64                                                                                                                                                                                          2/19 
  正在更新    : httpd-tools-2.4.6-90.el7.centos.x86_64                                                                                                                                                                                 3/19 
  正在更新    : httpd-2.4.6-90.el7.centos.x86_64                                                                                                                                                                                       4/19 
  正在更新    : httpd-devel-2.4.6-90.el7.centos.x86_64                                                                                                                                                                                 5/19 
  正在更新    : 1:mod_ssl-2.4.6-90.el7.centos.x86_64                                                                                                                                                                                   6/19 
  正在更新    : httpd-manual-2.4.6-90.el7.centos.noarch                                                                                                                                                                                7/19 
  正在更新    : 1:mariadb-server-5.5.64-1.el7.x86_64                                                                                                                                                                                   8/19 
  正在安装    : php-mysql-5.4.16-46.el7.x86_64                                                                                                                                                                                         9/19 
  正在更新    : 1:mariadb-devel-5.5.64-1.el7.x86_64                                                                                                                                                                                   10/19 
  清理        : httpd-manual-2.4.6-88.el7.centos.noarch                                                                                                                                                                               11/19 
  清理        : 1:mod_ssl-2.4.6-88.el7.centos.x86_64                                                                                                                                                                                  12/19 
  清理        : 1:mariadb-devel-5.5.60-1.el7_5.x86_64                                                                                                                                                                                 13/19 
  清理        : httpd-devel-2.4.6-88.el7.centos.x86_64                                                                                                                                                                                14/19 
  清理        : 1:mariadb-server-5.5.60-1.el7_5.x86_64                                                                                                                                                                                15/19 
  清理        : httpd-2.4.6-88.el7.centos.x86_64                                                                                                                                                                                      16/19 
  清理        : 1:mariadb-5.5.60-1.el7_5.x86_64                                                                                                                                                                                       17/19 
  清理        : httpd-tools-2.4.6-88.el7.centos.x86_64                                                                                                                                                                                18/19 
  清理        : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                                                                                                                                  19/19 
  验证中      : 1:mariadb-5.5.64-1.el7.x86_64                                                                                                                                                                                          1/19 
  验证中      : 1:mariadb-libs-5.5.64-1.el7.x86_64                                                                                                                                                                                     2/19 
  验证中      : httpd-devel-2.4.6-90.el7.centos.x86_64                                                                                                                                                                                 3/19 
  验证中      : httpd-tools-2.4.6-90.el7.centos.x86_64                                                                                                                                                                                 4/19 
  验证中      : php-mysql-5.4.16-46.el7.x86_64                                                                                                                                                                                         5/19 
  验证中      : httpd-2.4.6-90.el7.centos.x86_64                                                                                                                                                                                       6/19 
  验证中      : 1:mariadb-devel-5.5.64-1.el7.x86_64                                                                                                                                                                                    7/19 
  验证中      : 1:mod_ssl-2.4.6-90.el7.centos.x86_64                                                                                                                                                                                   8/19 
  验证中      : 1:mariadb-server-5.5.64-1.el7.x86_64                                                                                                                                                                                   9/19 
  验证中      : httpd-manual-2.4.6-90.el7.centos.noarch                                                                                                                                                                               10/19 
  验证中      : 1:mariadb-server-5.5.60-1.el7_5.x86_64                                                                                                                                                                                11/19 
  验证中      : httpd-devel-2.4.6-88.el7.centos.x86_64                                                                                                                                                                                12/19 
  验证中      : httpd-manual-2.4.6-88.el7.centos.noarch                                                                                                                                                                               13/19 
  验证中      : httpd-2.4.6-88.el7.centos.x86_64                                                                                                                                                                                      14/19 
  验证中      : 1:mod_ssl-2.4.6-88.el7.centos.x86_64                                                                                                                                                                                  15/19 
  验证中      : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                                                                                                                                  16/19 
  验证中      : 1:mariadb-5.5.60-1.el7_5.x86_64                                                                                                                                                                                       17/19 
  验证中      : httpd-tools-2.4.6-88.el7.centos.x86_64                                                                                                                                                                                18/19 
  验证中      : 1:mariadb-devel-5.5.60-1.el7_5.x86_64                                                                                                                                                                                 19/19 

已安装:
  php-mysql.x86_64 0:5.4.16-46.el7                                                                                                                                                                                                          

更新完毕:
  httpd.x86_64 0:2.4.6-90.el7.centos                                                                                  mariadb-server.x86_64 1:5.5.64-1.el7                                                                                 

作为依赖被升级:
  httpd-devel.x86_64 0:2.4.6-90.el7.centos  httpd-manual.noarch 0:2.4.6-90.el7.centos  httpd-tools.x86_64 0:2.4.6-90.el7.centos  mariadb.x86_64 1:5.5.64-1.el7  mariadb-devel.x86_64 1:5.5.64-1.el7  mariadb-libs.x86_64 1:5.5.64-1.el7 
  mod_ssl.x86_64 1:2.4.6-90.el7.centos     

完毕!
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 三 2019-09-18 16:33:50 CST; 15s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 68389 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─68389 /usr/sbin/httpd -DFOREGROUND
           ├─68390 /usr/sbin/httpd -DFOREGROUND
           ├─68392 /usr/sbin/httpd -DFOREGROUND
           ├─68393 /usr/sbin/httpd -DFOREGROUND
           ├─68394 /usr/sbin/httpd -DFOREGROUND
           ├─68395 /usr/sbin/httpd -DFOREGROUND
           └─68397 /usr/sbin/httpd -DFOREGROUND

9月 18 16:33:50 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
9月 18 16:33:50 localhost.localdomain httpd[68389]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
9月 18 16:33:50 localhost.localdomain systemd[1]: Started The Apache HTTP Server.

[root@localhost ~]# firewall-cmd --add-service="http"
success
[root@localhost ~]# firewall-cmd --permanent --add-service="http"
success
[root@localhost ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client http
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

打开浏览器浏览

http://localhost

完全没有任何问题。完美

 

 

 

 

 利用默认安装 SRPM文件  (--rebuid/--recompile)

 

 

 

 

 

SRPM使用的路径与需要的软件

         

 

 

 

   

 

转载于:https://www.cnblogs.com/Lonelychampion/p/11535699.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值