Linux at,crontab的使用以及apache的安装以及访问

目录

1.at 配置在5分钟后,将 "This is a at task" 写入 root家目录中的at_test文件中

2.crontab配置,每周六,周日 9点半,14点 提醒我上RHCE课 写入root家目录中的cron_test文件中

3.安装apache服务器:

并在/var/www/html新建index.html文件          

index.html文件内容:"This is my first web page"

然后在浏览器中输入192.168.xxx.xxx的ip访问


1.at 配置在5分钟后,将 "This is a at task" 写入 root家目录中的at_test文件中

#需要到 /var/spool/的目录下配置at
[root@rhcse ~]# cd /var/spool/
[root@rhcse spool]# at now + 5 minutes
warning: commands will be executed using /bin/sh
at> echo "This is a at task" > /root/at_task
#按住CTRL + D 结束
at> <EOT>
job 8 at Fri Dec 10 22:55:00 2021
[root@rhcse spool]# 



#结果:
[root@rhcse ~]# vim at_task 

This is a at task
~                 

2.crontab配置,每周六,周日 9点半,14点 提醒我上RHCE课 写入root家目录中的cron_test文件中

[root@rhcse cron]#  crontab -e
no crontab for root - using an empty one
crontab: installing new crontab

[root@rhcse ~]# crontab -l
30 9 * * 1-5 echo " GO TO RHCSE CLASS!" > /root/cron_test
0 14 * * 1-5 echo "GO TO RHCSE CLASS" >> /root/cron_test


[root@rhcse ~]# 

 

 

minute hour day month week command

minute: 表示分钟,可以是从0到59之间的任何整数。

hour:表示小时,可以是从0到23之间的任何整数。

day:表示日期,可以是从1到31之间的任何整数。

month:表示月份,可以是从1到12之间的任何整数。也可是日期的英文缩写

week:表示星期几,可以是从0到7之间的任何整数,这里的0或7代表星期日。

command:要执行的命令,可以是系统命令,也可以是自己编写的脚本文件。

以上各个字段可以使用的特殊字符
星号(*):代表所有可能的值,例如month字段如果是星号,则表示在满足其它字段的制约条件后每月都执行该命令操作。
逗号(,):可以用逗号隔开的值指定一个列表范围,例如,“1,2,5,7,8,9”
中杠(-):可以用整数之间的中杠表示一个整数范围,例如“2-6”表示“2,3,4,5,6”
正斜线(/):可以用正斜线指定时间的间隔频率,例如“0-23/2”表示每两小时执行一次。
           同时正斜线可以和星号一起使用,例如*/10,如果用在minute字段,表示每十分钟执行一次。

3.安装apache服务器:

[root@rhcse yum.repos.d]# yum install httpd -y
#启动服务
[root@rhcse yum.repos.d]# service httpd start

并在/var/www/html新建index.html文件          

index.html文件内容:"This is my first web page"

[root@rhcse yum.repos.d]# echo "This is my first web page" > /var/www/html/index.html

# 注意!!!
#修改配置之后一定要重启服务
#否则不会生效
[root@rhcse html]# service httpd restart 
Redirecting to /bin/systemctl restart httpd.service

然后在浏览器中输入192.168.xxx.xxx的ip访问

 

 

 

Supongo que te gusta

Origin blog.csdn.net/weixin_59280309/article/details/121873235
Recomendado
Clasificación