每天使用cron 12AM自动重新启动apache服务 [英] restart apache service automatically using cron 12AM daily
本文介绍了每天使用cron 12AM自动重新启动apache服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在测试服务器中安装了CentOs.
I have a CentOs setup in test server.
我想每天执行一次cron作业(cron需要在凌晨12点运行apache服务器).
I wanna to run a cron job (the cron needs to run apache server at 12AM) daily.
我的cron.daily饲料商位于/etc/cron.daily
My cron.daily fodler is located in /etc/cron.daily
请让我知道如何实现此步骤.
Please let me know the steps how to implement this.
通常,我使用以下命令来重新启动apache服务:
Usually I use to restart the apache service using the below command:
service httpd restart
我想每天使用cron 12AM自动重启apache服务.
I wanna to do restart apache service automatically using cron 12AM daily.
谢谢.
推荐答案
我明白了,并逐步为您添加了cron作业到您的系统中:
I got it and give you step by step adding cron jobs into your system:
- 使用SSH登录到服务器
- 键入
crontab -l
以显示cron作业列表, - 键入
crontab -e
来编辑您的crontab, - 添加
0 4 * * * /etc/init.d/mysqld restart
每天凌晨4点重新启动Mysql, - 添加
0 5 * * * /etc/init.d/httpd restart
每天每天凌晨5点重新启动Apache,并且 - 添加
0 24 * * * /etc/init.d/httpd restart
每天12点重新启动Apache - 保存文件,
- 用
crontab -l
重新检查
- Login to your server with SSH
- Type
crontab -l
to display list of cron jobs, - Type
crontab -e
to edit your crontab, - Add
0 4 * * * /etc/init.d/mysqld restart
to restart Mysql everyday at 4 AM, - Add
0 5 * * * /etc/init.d/httpd restart
to restart Apache everyday at 5 AM and - Add
0 24 * * * /etc/init.d/httpd restart
to restart Apache everyday at 12 AM - Save your file,
- Recheck with
crontab -l
这篇关于每天使用cron 12AM自动重新启动apache服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文