Results 1 to 6 of 6
Thread: CentOS 5 Startup script..?
-
07-07-2011, 11:17 AM #1Junior Guru Wannabe
- Join Date
- Oct 2009
- Posts
- 78
CentOS 5 Startup script..?
Hi,
I'm not that good at CentOS and the last time I attempted a startup script I broke my VPS for a good few hours, so I thought this could be a good site to ask for some advice.
I would like to create a startup script that does the following:
- Starts MySQL Service
- Goes to a directory and runs a SH script.
Could anyone help me out with creating a startup script properly?
Thanks.
-
08-05-2011, 12:35 PM #2Junior Guru
- Join Date
- Apr 2011
- Posts
- 235
Hi,
You can edit the /etc/rc.local file.
A default one (mine) looks like this:
----------
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
------------------------------
To start mysql automatically, just add on a new line:
/etc/init.d/mysqld start
OR
/sbin/service mysqld start
To run your custom script ONLY after mysql has started, you can use the && operand, e.g.
/sbin/service mysqld start && /path/to/customshellscript.sh
-
08-06-2011, 01:50 AM #3(formerly WhichGunDotCom)
- Join Date
- Jun 2011
- Location
- Woodbridge, NJ
- Posts
- 840
Here is the proper way to start MySQL automatically on boot with a CentOS 5.x system:
Code:sudo chkconfig mysqld on
Code:sudo /sbin/chkconfig mysqld on
Code:chkconfig --list
As before, if /sbin is not in your path, simply run "/sbin/chkconfig --list".
You can set other services to start (or not to start) on boot. For example, to set Apache to start at boot:
Code:sudo chkconfig httpd on
Code:/path/to/script.sh
-
08-06-2011, 01:57 AM #4(formerly WhichGunDotCom)
- Join Date
- Jun 2011
- Location
- Woodbridge, NJ
- Posts
- 840
Also, you can use the chkconfig command to set other services to start (or not to start) on boot.
To set Apache to start automatically on boot:
Code:sudo chkconfig httpd on
Code:sudo chkconfig sendmail off
-
08-06-2011, 11:46 AM #5Junior Guru
- Join Date
- Apr 2011
- Posts
- 235
-
08-22-2011, 11:42 AM #6New Member
- Join Date
- Mar 2010
- Posts
- 2
Similar Threads
-
Startup Script
By Scott_CFR in forum VPS HostingReplies: 2Last Post: 08-19-2010, 09:58 AM -
Setting a startup process - CentOS
By csparks in forum Hosting Security and TechnologyReplies: 4Last Post: 05-20-2009, 12:35 AM -
CentOS - Add perl script to system startup
By ThatScriptGuy in forum Hosting Security and TechnologyReplies: 11Last Post: 09-17-2007, 06:08 PM -
Problem running FreeNX. Session Startup Failed. CentOS 5, Dont think GNOME works!HELP
By CrewXp in forum Hosting Security and TechnologyReplies: 0Last Post: 08-13-2007, 05:14 PM -
CentOS 4.4 and Startup Scripts
By Ryan F in forum Hosting Security and TechnologyReplies: 16Last Post: 08-31-2006, 08:15 PM