每天使用cron 12AM自动重新启动apache服务 [英] restart apache service automatically using cron 12AM daily

查看:88
本文介绍了每天使用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:

  1. 使用SSH登录到服务器
  2. 键入crontab -l以显示cron作业列表,
  3. 键入crontab -e来编辑您的crontab,
  4. 添加0 4 * * * /etc/init.d/mysqld restart每天凌晨4点重新启动Mysql,
  5. 添加0 5 * * * /etc/init.d/httpd restart每天每天凌晨5点重新启动Apache,并且
  6. 添加0 24 * * * /etc/init.d/httpd restart每天12点重新启动Apache
  7. 保存文件,
  8. crontab -l
  9. 重新检查
  1. Login to your server with SSH
  2. Type crontab -l to display list of cron jobs,
  3. Type crontab -e to edit your crontab,
  4. Add 0 4 * * * /etc/init.d/mysqld restart to restart Mysql everyday at 4 AM,
  5. Add 0 5 * * * /etc/init.d/httpd restart to restart Apache everyday at 5 AM and
  6. Add 0 24 * * * /etc/init.d/httpd restart to restart Apache everyday at 12 AM
  7. Save your file,
  8. Recheck with crontab -l

这篇关于每天使用cron 12AM自动重新启动apache服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆