?
Solved

bootup script to stop apache, start a service on the machine, start apache.

Posted on 2007-10-17
16
Medium Priority
?
274 Views
Last Modified: 2010-04-16
I want to create a batch file that gets run on machine boot to do the following.

Stops apache web server
changes to a directory where I have a web application
starts a service in that directory
restarts apache.

Is this possible?  I have 2 applications I would like to have this happen to every time the machine reboots?
0
Comment
Question by:urobins
  • 11
  • 5
16 Comments
 
LVL 6

Expert Comment

by:nathana21
ID: 20093330
well i don't know about inserting it in boot, but this would be the script

apachectl stop
cd /
cd <web app directory>
apachectl start
0
 
LVL 6

Expert Comment

by:nathana21
ID: 20093349
To run it at startup put the script in /etc/init.d
0
 

Author Comment

by:urobins
ID: 20093369
is that directory under the apache directory?
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 6

Expert Comment

by:nathana21
ID: 20093384
So to recap this is the script

#!/bin/bash
apachectl stop
cd /
cd <web app directory>
apachectl start

-----------------------------------------
put it in /etc/init.d/boot.local
0
 
LVL 6

Expert Comment

by:nathana21
ID: 20093404
the command should be in the path. The directory <> is a placeholder.
0
 
LVL 6

Expert Comment

by:nathana21
ID: 20093437
OH sorry i forgot something...

#!/bin/bash
apachectl stop
cd /
cd <web app directory>
<command to start desired service>
apachectl start
0
 

Author Comment

by:urobins
ID: 20093513
Oh sorry the problem is this is running on a win2k3 server box.
0
 
LVL 6

Expert Comment

by:nathana21
ID: 20093565
oh ok. i can mod it real quick. Its easier with a w2k3, just put the command to run the batch file i will post in ad
0
 
LVL 6

Accepted Solution

by:
nathana21 earned 2000 total points
ID: 20093611
Save the following as <desired filename>.cmd

httpd -k stop
cd \
cd <web app directory>
net start <service name>
httpd -k start
0
 
LVL 6

Expert Comment

by:nathana21
ID: 20093681
0
 
LVL 6

Expert Comment

by:nathana21
ID: 20093761
Running scripts as a login script

http://www.rlmueller.net/LogonScriptFAQ.htm
0
 

Author Comment

by:urobins
ID: 20093933
Can this be don to run as a task at boot instead of a logon script?  Nobody logs onto this box, so I am really looking to just have it run in the event the machine gets rebooted via update or some other strange occurrence.
0
 
LVL 6

Expert Comment

by:nathana21
ID: 20094055
0
 
LVL 6

Expert Comment

by:nathana21
ID: 20094069
ignore the Two hour thing of course, but the installation principle should be the same.
0
 

Author Comment

by:urobins
ID: 20094112
Thanks, I'll have a look at this, I appreciate it.
0
 

Author Comment

by:urobins
ID: 20095670
Thanks works like a champ!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question