Auto Shutdown and Restart Apache HTTPD Service Daemon at Preset Time Auto Shutdown và khởi động lại Apache httpd Service Daemon at Preset Thời gian
The core component of any websites, blogs, web services and web applications is the web server. Các thành phần cốt lõi của bất kỳ trang web, blog, dịch vụ web và các ứng dụng web là máy chủ web. And Apache is the most popular HTTP server that powers the websites worldwide. Apache và HTTP là phổ biến nhất của máy chủ mà quyền hạn của các trang web trên toàn thế giới. 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. Điều quan trọng để đảm bảo rằng thời gian hoạt động và liên tục chạy của Apache dịch vụ hoặc daemon trên server, vì nếu là dịch vụ httpd xuống, trang web của bạn sẽ được unaccessible cho du khách. 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. Khác hơn là sử dụng dịch vụ giám sát, tập lệnh hoặc tiện ích để kiểm tra xem daemon httpd là lên, máy chủ quản trị viên cũng có một sự lựa chọn để khởi động lại dịch vụ Apache theo định kỳ.
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. Tắt máy và khởi động lại Apache định kỳ tại khoảng cụ thể giúp đảm bảo rằng các dịch vụ web Apache luôn luôn trong tình trạng chạy đỉnh cao, không có hiệu lực của rò rỉ bộ nhớ có thể và nguồn lực hogging bởi các kết nối liên tục. 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. Nó cũng đảm bảo rằng thời gian ngừng các trang web được giới hạn trong việc tiếp theo lịch trình khởi động lại, chỉ trong trường hợp nó là như vậy không may mắn rằng Apache bị treo vô thời hạn và các dịch vụ giám sát của bạn không thể nhận các sự cố.
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. Để tắt máy và bắt đầu Apache tự động, chúng tôi có thể làm cho việc sử dụng crontab (hoặc theo lịch trình công tác hoặc Task Scheduler trong Windows Server) vào lịch trình làm nhiệm vụ tại thời điểm thích. Simply edit the cron jobs with a root or whell user, and add in the following line: Đơn giản chỉ cần sửa các công việc cron với một người chủ hoặc người sử dụng whell, và thêm vào dòng sau:
mhdmw /usr/local/apache/bin/apachectl restart mhdmw / usr / local / apache / bin / apachectl khởi động lại
Replace m, h, d, m and w with value of your preference, where they represent the following meaning: Thay thế m, h, d, m và w với giá trị của sở thích của bạn, nơi họ đại diện cho ý nghĩa sau đây:
m: min (0 – 59) m: min (0-59)
h: hour (0 – 23) h: hour (0-23)
d: day of month (1 – 31) d: ngày trong tháng (1-31)
m: month (1 – 12) m: tháng (1-12)
w: day of week (0 – 6) (Sunday=0) w: ngày trong tuần (0-6) (Chủ nhật = 0)
For variables that you want to happen every time, set it as * (asterisk). Đối với các biến mà bạn muốn để xảy ra mọi thời gian, thiết lập nó như là * (dấu sao).
For example, to kill the Apache daemon and start it immediately at 1 AM every night, set the crontab line to: Ví dụ, để giết daemon Apache và bắt đầu ngay lúc 01:00 mỗi đêm, thiết lập các đường dây crontab tới:
0 1 * * * /usr/local/apache/bin/apachectl restart 0 1 * * * / usr / local / apache / bin / apachectl khởi động lại
To restart Apache HTTPD service on weekend, such as Sunday 12 noon, use the following cron job: Để khởi động lại Apache httpd dịch vụ vào cuối tuần, như Chủ Nhật 12 giờ trưa, sử dụng các công việc cron sau đây:
0 12 * * 0 /usr/local/apache/bin/apachectl restart 0 12 * * 0 / usr / local / apache / bin / apachectl khởi động lại
You can input “man crontab” to learn more about cron jobs in Linux/Unix/FreeBSD/CentOS. Bạn có thể nhập vào "man crontab" để tìm hiểu thêm về công việc cron trong Linux / Unix / FreeBSD / CentOS. To edit the crontab job list, simply enter “crontab -e” on the shell. Để chỉnh sửa danh sách công việc crontab, chỉ cần nhập "crontab-e" trên vỏ. Existing crontab will appear on a text editor, such as GNU nano. Hiện có crontab sẽ xuất hiện trên một trình soạn thảo văn bản, chẳng hạn như GNU nano. 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. Nếu đây là trường hợp, thực hiện những thay đổi cần thiết, sau đó ấn phím "Ctrl-X", theo do "Y" để lưu tập tin, và làm theo bằng cách bấm phím Enter để chấp nhận các tên tập tin mặc định. The new crontab will be installed and in effect immediately. The crontab mới sẽ được cài đặt và có hiệu lực ngay lập tức.
Note that the path to apachectl may be different on different variant of Unix, Linux or BSD flavors. Lưu ý rằng đường dẫn đến apachectl có thể khác nhau về biến thể khác nhau của Unix, Linux hay BSD hương vị. Use one of the following command to find out where is Apache installed: Sử dụng một trong các lệnh sau để tìm nơi Apache được cài đặt:
find / apachectl | grep apachectl find / 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. Một số Apache có thể cài đặt trong / usr / sbin / apachectl, hoặc bạn có thể sử dụng httpd hoặc apachectl symbolic link trong / etc / rc.d / init.d / apachectl hoặc / etc / rc.d / init.d / httpd.
IMPORTANT : The page is machine translated and provided "as is" without warranty. Quan trọng: Sửa là máy dịch và cung cấp "như là" không có bảo hành. Machine translation may be difficult to understand. Máy dịch thuật có thể khó hiểu. Please refer to Vui lòng tham khảo original English article bản gốc tiếng Anh bài viết whenever possible. bất cứ khi nào có thể.
Related Articles Bài viết liên quan
- Start, Stop and Restart Crond Daemon in Linux Bắt đầu, Dừng và khởi động lại Crond Daemon trong Linux
- Starting Apache HTTPD Failed Due to Cannot Open or No Such mod_bwlimited, mod_log_bytes or mod_bandwidth Files Bắt đầu từ Apache httpd Không Do không thể mở hay không mod_bwlimited, mod_log_bytes như vậy hay mod_bandwidth Files
- Automatically Shutdown Computer With Auto Shutdown Genius Tự động tắt máy tính Với Genius Auto Shutdown
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 4 Cài đặt Web Server trong FreeBSD 6,0 với 2,2 Apache, MySQL 5.0 và PHP 5 - Phần 4
- How to Disable Linux and Unix Cron Jobs (Crontab) Email Sending Làm thế nào để Disable Linux và Unix Cron Jobs (Crontab) Email Gửi
- How to Restart (Stop or Start) cPanel Service (cpsrvd) via Telnet or SSH Làm thế nào để Khởi động lại (Stop hoặc Start) cPanel Dịch vụ (cpsrvd) thông qua Telnet hay SSH
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 5 Cài đặt Web Server trong FreeBSD 6,0 với 2,2 Apache, MySQL 5.0 và PHP 5 - Phần 5
- Request URL /server-status or 404 Page Not Found Apache Error Yêu cầu URL / server-status hoặc 404 Không tìm thấy trang Apache Error
- Restart or Shutdown Windows (XP, 2000 and Vista) from Command Line or One-Click Shortcut Khởi động lại hay tắt Windows (XP, 2000 và Vista) từ Command Line hay One-Click Shortcut
- cPanel Unable or Cannot Start or Restart POP3 Mail Service cPanel Không thể hoặc có thể không bắt đầu hoặc khởi động lại dịch vụ POP3 Mail









































