#!/bin/bash
# These instructions apply to CentOS distros
sudo nano /etc/init.d/service-name
# write your script
# make sure it has chkconfig header like below
# #!/bin/sh
# chkconfig: 0123456 95 20
# description: A foo service.
# processname: foo
# Add service called foo
sudo chkconfig --add foo
# Del service called foo
sudo chkconfig --del foo
# List status for foo
chkconfig --list foo
# Turn on or off services
sudo chkconfig foo on
sudo chkconfig foo off
sudo chkconfig --level 2 foo on
sudo chkconfig --level 35 foo on