Link to home
Start Free TrialLog in
Avatar of detox1978
detox1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

CentOS: Set service to auto start

hi All,

I recently hired a VPS.  I have everything setup as i want it.  But went the server is rebooted it doesn;t automatically start the FTP and MySQL services.  So i have to manually type;


/etc/init.d/vsftpd start;
/etc/init.d/mysqld start;


How do i configure these services to automatically start?
Avatar of jeremycrussell
jeremycrussell
Flag of United States of America image

Couple ways...

Look at "chkconfig" you can use this to manage service startup.. may require some modification of the init scripts..

Second way..

type "runlevel" to get what run level the server normally boots into, probably 3 or 5, you can also look at /etc/inittab.

Then, depending on the leve, go to the /etc/rc?.d directory.. so for runlevel 5 it would be /etc/rc5.d
in that directory, just link to the init script for the *S*tartup.

ln -s ../init.d/mysqld S99mysql
ln -s ../init.d/vsftpd S99vsftpd


If you would like, you can create corresponding links in runlevels to *stop* the services...  For example to kill the service when the machine is shutdown:

cd /etc/rc0.d/;ln -s ../init.d/K99mysqld

run "man init" to get more info on the runlevels at which level is "inited" when.
Correction:

cd /etc/rc0.d/;ln -s ../init.d/K99mysqld

should read
cd /etc/rc0.d/;ln -s ../init.d/mysqld K01mysqld
SOLUTION
Avatar of TRW-Consulting
TRW-Consulting
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
Avatar of detox1978

ASKER

I had a look at the chkconfig and both services are listed as off. How do i edit the config so they are on?
ASKER CERTIFIED SOLUTION
Avatar of Kerem ERSOY
Kerem ERSOY

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
Many thanks,

I have another CentOS question about switching off cron notifications if you have time.

https://www.experts-exchange.com/questions/26559002/CentOS-Disable-cron-notifications.html
To stop the cron e-mail notifications just apped 2>&1 to end of the command.

Regards

P.S. You can use chkconfig --list to see what services are currently set to run.
      To start|stop a service for a run-level issue chkconfig --level <levels> <service_name> on|off
      To add a service to chkconfig issue chkconfig --add <service_name>

Hope that helps.