Auto Shutdown and Restart Apache HTTPD Service Daemon at Preset Time自动关机和重新启动了Apache的httpd服务守护进程在预设时间
The core component of any websites, blogs, web services and web applications is the web server.的核心组成部分,任何网站,博客,网络服务和网络应用是Web服务器。 And Apache is the most popular HTTP server that powers the websites worldwide.和Apache是最流行的HTTP服务器,权力全世界的网站。 It’s important to ensure that the uptime and continuous running of Apache service or daemon on the server, as if HTTPD service is down, your website will be unaccessible to the visitors.重要的是要确保正常运行和持续运行的Apache服务或守护进程的服务器上,仿佛的httpd服务下来,您的网站将无法使用参观者。 Other than using monitoring service, script or utility to check if the HTTPD daemon is up, server administrator also has a choice to restart the Apache service periodically.除了使用监控服务,脚本或实用工具来检查,如果的httpd守护进程是,服务器管理员也可以选择重新启动Apache的定期服务。
Shutdown and restart Apache periodically at specific interval helps to ensure that Apache web service is always running in top notch condition, without effect of possible memory leak and resource hogging by persistent connections.关机和重新启动了Apache定期在特定时间间隔有助于确保Apache网络服务始终运行在顶尖状态,而不影响可能内存泄漏和资源占用的持久连接。 It also ensure that the web sites downtime is limited to the next restart schedule, just in case it’s so unlucky that Apache hangs indefinitely and your monitoring service can’t pick up the incident.它还确保网站宕机时间限定为在下次重新启动的时间表,以防万一这么倒霉的阿帕奇挂起无限期地和你的监测服务无法收拾事件。
To shutdown and start Apache automatically, we can make use of crontab (or Scheduled Task or Task Scheduler in Windows Server) to schedule the task at the time prefer.要关闭和启动Apache自动,我们可以使用crontab (或排定的工作或任务计划程序在Windows Server ) ,以计划任务的时候喜欢。 Simply edit the cron jobs with a root or whell user, and add in the following line:只需编辑职位玉米根或whell用户,并加上下面一行:
mhdmw /usr/local/apache/bin/apachectl restart mhdmw的/ usr / local /阿帕奇/斌/ apachectl重新启动
Replace m, h, d, m and w with value of your preference, where they represent the following meaning:替换米,小时,天,米和w的价值,您的喜好,他们代表下列含义:
m: min (0 - 59)男:民( 0 -5 9)
h: hour (0 - 23)小时:小时( 0 -2 3)
d: day of month (1 - 31) D组:每月一天( 1 -3 1)
m: month (1 - 12)男:一个月( 1 -1 2)
w: day of week (0 - 6) (Sunday=0)瓦特:一周内每天的( 0 -6 ) (星期日= 0 )
For variables that you want to happen every time, set it as * (asterisk).对于变量,你想每一次发生,设置为* (星号) 。
For example, to kill the Apache daemon and start it immediately at 1 AM every night, set the crontab line to:例如,如果要杀死的Apache守护进程,并立即开始于凌晨1时每天晚上,设置crontab线:
0 1 * * * /usr/local/apache/bin/apachectl restart 0 1 * * *的/ usr / local /阿帕奇/斌/ apachectl重新启动
To restart Apache HTTPD service on weekend, such as Sunday 12 noon, use the following cron job:为了重新启动了Apache的httpd服务上周末,如星期日中午12时,请使用下列作业:
0 12 * * 0 /usr/local/apache/bin/apachectl restart 0 12 * * 0的/ usr / local /阿帕奇/斌/ apachectl重新启动
You can input “man crontab” to learn more about cron jobs in Linux/Unix/FreeBSD/CentOS.您可以输入“人crontab ” ,以了解更多关于就业玉米在Linux / UNIX / FreeBSD的/ CentOS 。 To edit the crontab job list, simply enter “crontab -e” on the shell.编辑crontab的工作清单中,只需输入“ crontab娥”的空壳。 Existing crontab will appear on a text editor, such as GNU nano.现有的crontab会出现在文字编辑器,如纳米的GNU 。 If this is the case, make the necessary changes, then press “Ctrl-X”, follow by “Y” to save the file, and follow by Enter press to accept the default file name.如果是这种情况,作必要的修改,然后按“按Ctrl - X ”的,后续的“ Y ”型,以保存该文件,并按照记者的输入,以接受默认的文件名。 The new crontab will be installed and in effect immediately.新的crontab将被安装并立即生效。
Note that the path to apachectl may be different on different variant of Unix, Linux or BSD flavors.请注意,路径apachectl可能会有所不同不同的变异的Unix , Linux或BSD的味道。 Use one of the following command to find out where is Apache installed:使用下列其中一个命令,以找出是Apache的安装:
find / apachectl | grep apachectl找到/ apachectl | grep apachectl
whereis apachectl whereis apachectl
Some Apache may install in /usr/sbin/apachectl, or you can use the httpd or apachectl symbolic links in /etc/rc.d/init.d/apachectl or /etc/rc.d/init.d/httpd.一些阿帕奇可安装在/ usr / sbin / apachectl ,或您可以使用的httpd或apachectl符号链接在/ etc / rc.d / init.d / apachectl或/ etc / rc.d / init.d /的httpd 。
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要说明:这是一台机器翻译网页这是“原样”提供,无保修。 Machine translation may be difficult to understand.机器翻译可能很难理解。 Please refer to请参阅 original English article英文原文的文章 whenever possible.只要有可能。
Share and contribute or get technical support and help at共享和贡献或获得技术支持和帮助 My Digital Life Forums 我的数字生活论坛 . 。
Related Articles相关文章
- Start, Stop and Restart Crond Daemon in Linux启动,停止和重新启动Crond守护在Linux
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 4安装Web服务器的FreeBSD 6.0与Apache 2.2 , MySQL的5.0和PHP 5 -第4部分
- Starting Apache HTTPD Failed Due to Cannot Open or No Such mod_bwlimited, mod_log_bytes or mod_bandwidth Files从阿帕奇的httpd ,却因为无法打开或没有这样的mod_bwlimited , mod_log_bytes或mod_bandwidth档案
- Apache Warn NameVirtualHost *:80 Has No VirtualHosts Error When Start阿帕奇警告NameVirtualHost * : 80没有VirtualHosts启动时出现错误
- Install mod_evasive for Apache to Prevent DDOS Attacks mod_evasive安装的Apache防止DDOS攻击
- Restart or Shutdown Windows (XP, 2000 and Vista) from Command Line or One-Click Shortcut重新启动或关机的Windows ( XP中, 2000年和Vista )由命令行或一点击捷径
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 2 Web服务器安装在Windows XP中使用的Apache2 , PHP5和MySQL4 -第2部分
- Improve Apache Web Server Security: Use ServerTokens and ServerSignature to Disable Header提高Apache Web服务器安全:使用ServerTokens和ServerSignature禁用头
- Apache Status (whm-server-status) in cPanel WebHost Manager Returns Blank Page阿帕奇地位(的WHM服务器的地位)在的cPanel虚拟主机提供商联系管理员返回空白页
- cPanel WHM Failed to Receive Status Information From Apache Error的cPanel的WHM没有获得状态信息,从阿帕奇误差
































