Link to home
Start Free TrialLog in
Avatar of urobins
urobins

asked on

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

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?
Avatar of nathana21
nathana21
Flag of United States of America image

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
To run it at startup put the script in /etc/init.d
Avatar of urobins
urobins

ASKER

is that directory under the apache directory?
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
the command should be in the path. The directory <> is a placeholder.
OH sorry i forgot something...

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

ASKER

Oh sorry the problem is this is running on a win2k3 server box.
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
ASKER CERTIFIED SOLUTION
Avatar of nathana21
nathana21
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Running scripts as a login script

http://www.rlmueller.net/LogonScriptFAQ.htm
Avatar of urobins

ASKER

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.
ignore the Two hour thing of course, but the installation principle should be the same.
Avatar of urobins

ASKER

Thanks, I'll have a look at this, I appreciate it.
Avatar of urobins

ASKER

Thanks works like a champ!