hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : VPS Hosting : VPS Tutorials : CentOS 5 Startup script..?
Reply

VPS Tutorials Tutorials related to VPS.
Forum Jump

CentOS 5 Startup script..?

Reply Post New Thread In VPS Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-07-2011, 11:17 AM
Zixt Zixt is online now
Junior Guru Wannabe
 
Join Date: Oct 2009
Posts: 77

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.

Reply With Quote


Sponsored Links
  #2  
Old 08-05-2011, 12:35 PM
vpswing vpswing is offline
WHT Addict
 
Join Date: Apr 2011
Posts: 153
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

Reply With Quote
  #3  
Old 08-06-2011, 01:50 AM
VectorVPS VectorVPS is offline
(formerly WhichGunDotCom)
 
Join Date: Jun 2011
Location: Woodbridge, NJ
Posts: 684
Here is the proper way to start MySQL automatically on boot with a CentOS 5.x system:

Code:
sudo chkconfig mysqld on
If you get a 'command not found' error, your path does not include /sbin (which is where the chkconfig command lives). You will need to either add /sbin to your path, or run this command:

Code:
sudo /sbin/chkconfig mysqld on
To verify, run this command:

Code:
chkconfig --list
Search for the row named 'mysqld'. Check that the mysql service is on for runlevel 3 (you should see 3n in this row).

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
To automatically run the bash script on boot, vpswing's instructions are correct. Edit /etc/rc.local and add a line at the end pointing towards the script:

Code:
/path/to/script.sh

Reply With Quote
Sponsored Links
  #4  
Old 08-06-2011, 01:57 AM
VectorVPS VectorVPS is offline
(formerly WhichGunDotCom)
 
Join Date: Jun 2011
Location: Woodbridge, NJ
Posts: 684
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
To set sendmail to not start automatically on boot:

Code:
sudo chkconfig sendmail off

Reply With Quote
  #5  
Old 08-06-2011, 11:46 AM
vpswing vpswing is offline
WHT Addict
 
Join Date: Apr 2011
Posts: 153
Quote:
Originally Posted by WhichGunDotCom View Post
Here is the proper way to start MySQL automatically on boot with a CentOS 5.x system:

Code:
sudo chkconfig mysqld on
If you get a 'command not found' error, your path does not include /sbin (which is where the chkconfig command lives). You will need to either add /sbin to your path, or run this command:

Code:
sudo /sbin/chkconfig mysqld on
To verify, run this command:

Code:
chkconfig --list
Search for the row named 'mysqld'. Check that the mysql service is on for runlevel 3 (you should see 3n in this row).

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
To automatically run the bash script on boot, vpswing's instructions are correct. Edit /etc/rc.local and add a line at the end pointing towards the script:

Code:
/path/to/script.sh

Thanks for that! I knew CentOS had something like Ubuntu's update-rc.d command - was too lazy to look it up and used the "rc.local" shortcut.

Reply With Quote
  #6  
Old 08-22-2011, 11:42 AM
nujum nujum is offline
New Member
 
Join Date: Mar 2010
Posts: 1
Quote:
Originally Posted by vpswing View Post
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
thx u help me that example for auto start my openVPN after boot...

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Startup Script Scott_CFR VPS Hosting 2 08-19-2010 09:58 AM
Setting a startup process - CentOS csparks Hosting Security and Technology 4 05-20-2009 12:35 AM
CentOS - Add perl script to system startup ThatScriptGuy Hosting Security and Technology 11 09-17-2007 06:08 PM
Problem running FreeNX. Session Startup Failed. CentOS 5, Dont think GNOME works!HELP CrewXp Hosting Security and Technology 0 08-13-2007 05:14 PM
CentOS 4.4 and Startup Scripts Ryan F Hosting Security and Technology 16 08-31-2006 08:15 PM

Related posts from TheWhir.com
Title Type Date Posted
SoftLayer Catalyst Program Supports Startup Texas Member Companies Web Hosting News 2013-02-11 13:55:15
Web Host Rackspace Adds FreeBSD 9, CentOS 6.3 Support to Cloud Servers Web Hosting News 2012-07-30 12:47:10
Web Host ServerPronto Donates Hosting Resources to CentOS Web Hosting News 2012-07-05 14:06:27
Peak Hosting Offers Subsidized Hosting Services to Startups Web Hosting News 2012-05-31 12:21:44
Web Host NetHosting Announces Support for CentOS 6 Web Hosting News 2011-07-05 20:15:20


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?