Apache timed automatic startup script program code

Source: Internet
Author: User

Linux operating methods

In linux, the apache service is installed (by downloading binary files for economical compilation and installation, rather than rpm packages) and the apache service startup command is:/server/apache/bin/apachectl start. Run the apache service under runlevel 3. The command is as follows:
  
1)

The code is as follows: Copy code
Touch/etc/rc. d/init. d/apache
Vi/etc/rc. d/init. d/apache
Chown-R root/etc/rc. d/init. d/apache
Chmod 700/etc/rc. d/init. d/apache
Ln-s/etc/rc. d/init. d/apache/etc/rc. d/rc3.d/S60apache

# S is short for start, meaning start, K is short for kill, and stands for close. The number 60 indicates the order of startup. (For the iptv system, many services can be started normally only when the database is started. You can adjust the script startup sequence with this number ))
     
Apache content:

The code is as follows: Copy code
#! /Bin/bash
# Start httpd service
/Server/apache/bin/apachectl start

      
Now the apache service can be automatically started at random under runtime level 3.


In windowsApache automatic restartCode

1. Create an autostartserver. bat file in the c: root directory, right-click it, set the file content to the following, and save it:

The code is as follows: Copy code
@ ECHO OFF
Net stop apache2
Net start apache2
Net stop mysql
Net start mysql

Note: The above apache2 and mysql are service names.

2. "start"-"run" cmd "-" run the command "at c:/autostartserver. bat"
In this way, the system automatically restarts apache and mysql at every morning.
Note: 04: 00 indicates the restart time, and c: autostartserver. bat indicates the bat file address in step 1.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.