RHCE-at练习-cron练习

一、配置仓库

准备工作

# 本地源
[root@localhost yum.repos.d] # cat base.repo
[base]
name = base
baseurl = file:///mnt/BaseOS
gpgcheck = 0
[app]
name = appstream
baseurl = file:///mnt/AppStream
gpgcheck = 0

1.建立网络源

在/etc/yum.repos.d/下配置.repo文件

[root@client ~]# cd /etc/yum.repos.d/
[root@client ~]# vim aliyun.repo
[appstream]
name=appstream
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/AppStream/x86_64/os/
gpgcheck=0

[baseos]
name=baseos
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/BaseOS/x86_64/os/
gpgcheck=0

配置详解:  

由于是网络源,baseurl中的信息是网址信息

这里用着阿里云的centos镜像源(阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区

由于用着Redhat9的镜像,因此这里选择centos stream源

 进入下载地址后选择9-stream/ 

 

 

 

 

 

得到的链接需删除 os/ 后的部分得到https://mirrors.aliyun.com/centos-stream/9-stream/BaseOS/x86_64/os/

这种形式的网络地址就是网络源的baseos的baseurl中的信息

同样的,appstream的baseurl:https://mirrors.aliyun.com/centos-stream/9-stream/AppStream/x86_64/os/

在yum.repos.d下能查看到:

 2.验证是否成功

 

[root@client yum.repos.d]# yum install gcc

 网络源建立成功! 

二、at练习

1.下载at

[root@client yum.repos.d]# yum install at

 2.at命令详解

命令格式: at [参数] [时间]

参数:
-m 当任务完成之后,即使没有标准输出,将给用户发送邮件
-l atq的别名,可列出目前系统上面的所有该用户的at调度
-d atrm的别名,可以取消一个在at调度中的工作
-v 使用较明显的时间格式,列出at调度中的任务列表
-c 可以列出后面接的该项工作的实际命令内容
-f 从文件中读取作作业
时间格式:
HH:MM 在今天的HH小时MM分钟执行,如果今天的这个时间点已经过了,则明
天执行
HH:MM YYYY-MM-DD 强制规定在某年某月的某一天的特殊时刻进行该工作
now + 2 minutes 从现在开始几分钟minutes, hours, days, or weeks

 # 定义三分钟之后显示 hello

三、cron练习

crontab命令详解

[root@client ~]# crontab --help
crontab: 不适用的选项 -- -
crontab: usage error: unrecognized option
Usage:
 crontab [options] file
 crontab [options]
 crontab -n [hostname]

Options:
 -u <user>  define user
 -e         edit user's crontab
 -l         list user's crontab
 -r         delete user's crontab
 -i         prompt before deleting
 -n <host>  set host in cluster to run users' crontabs
 -c         get host in cluster to run users' crontabs
 -T <file>  test a crontab file syntax
 -s         selinux context
 -V         print version and exit
 -x <mask>  enable debugging

Default operation is replace, per 1003.2

 

1.开启cron

[root@client ~]# systemctl status crond

2. 每天早上9点整说good morning

[root@client ~]# crontab -e
[root@client ~]# crontab -l
0 9 * * * wall "good morning"

 

[root@client ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值