1.at 配置在5小时后,将 “This is a at task” 写入 root家目录中的at_test文件中
答:
[root@localhost ~]# at now+5 hour
warning: commands will be executed using /bin/sh
at> echo "This is a at task" > /root/at_test
at> <EOT>
job 1 at Sat Nov 27 11:12:00 2021
[root@localhost ~]#
[root@localhost ~]# at -l
1 Sat Nov 27 11:12:00 2021 a root
因为这个时间太长,无法很快显示效果,我另外弄了一个1分钟的
结果如下
[root@localhost ~]# at now+1 minute
warning: commands will be executed using /bin/sh
at> echo This is a at task >> /root/at_test
at> <EOT>
job 3 at Sat Nov 27 06:20:00 2021
[root@localhost ~]# cat /root/at_test
This is a at task
[root@localhost ~]#
2.crontab配置,每周六,周日 9点半,14点 提醒我上RHCE课 写入root家目录中的cron_test文件中
答:
编辑crontab的工作内容
[root@localhost ~]# crontab -u root -e
vim中编写
30 9 * * 6-7 echo "上RHCE课" > /root/cron_test
0 14 * * 6-7 echo "上RHCE课" > /root/cron_test
查看crontab工作内容
[root@localhost ~]# crontab -u root -l
30 9 * * 6-7 echo "上RHCE课" > /root/cron_test
0 14 * * 6-7 echo "上RHCE课" > /root/cron_test
3.安装httpd,并将访问apache服务器的首页修改为hello.html, 且内容为: “My Home Page is hello”
答:
安装httpd:
#备份
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
总用量 4
-rw-r--r--. 1 root root 358 11月 22 05:19 redhat.repo
[root@localhost yum.repos.d]# mv redhat.repo redhat.repo.bak
下载
[root@localhost yum.repos.d]# wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
清除与建立
[root@localhost yum.repos.d]# yum clean all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
0 文件已删除
[root@localhost yum.repos.d]# yum makecache
安装软件
[root@localhost yum.repos.d]# yum install httpd -y
开启
[root@localhost html]# cd /etc/httpd/conf
[root@localhost conf]# vim httpd.conf
[root@localhost conf]# systemctl restart httpd
[root@localhost conf]# setenforce 0
[root@localhost conf]# systemctl stop firewalld
进入默认的首页所在目录
编辑内容
[root@localhost conf]# cd /var/www/html/
[root@localhost html]# ls
[root@localhost html]# vim index.html
结果:
4.虚拟主机:虚拟两台主机ip为100,200, 对应访问目录:/www/ip/100, /www/ip/200
并创建首页文件index.html
[root@localhost ip]# nmcli c modify ens160 +ipv4.addresses 192.168.155.100 ipv4.gateway 192.168.155.2 ipv4.method manual
[root@localhost ip]# nmcli c modify ens160 +ipv4.addresses 192.168.155.200 ipv4.gateway 192.168.155.2 ipv4.method manual
[root@localhost httpd]# mkdir -p /www/ip/{100,200}
[root@localhost ip]# nmcli c up ens160
进入
[root@localhost ~]# cd /etc/httpd/conf.d
[root@localhost conf.d]# vim myhosts.conf
编写:
<Directory>
AllowOverride none
Require all granted
</Directory>
#Listen 80
<VirtualHost 192.168.155.100:80>
DocumentRoot "/www/ip/100"
ServerName 192.168.155.100
</VirtualHost>
#Listen 80
<Virtualhost 192.168.155.200:80>
DocumentRoot "/www/ip/200"
ServerName 192.168.155.200
</VirtualHost>
[root@localhost conf.d]# echo "this is 200" > /www/ip/200/index.html
[root@localhost conf.d]# echo "this is 100" > /www/ip/100/index.html
启动
[root@localhost conf.d]# systemctl restart httpd
结果