How to Set auto-start for cenos startup

Source: Internet
Author: User

There are two main ways to enable cenos to enable auto-start

1. Add the Startup Program command to the/etc/rc. d/rc. Local folder.

Set eg1. start MySQL at startup

Vim/etc/rc. d/rc. Local #! /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 -- Update access time and modification time/usr/local/MySQL/bin/MySQL start

Eg2. set startup Tomcat

Vim/etc/rc. d/RC. local # 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. export catalina_base =/usr/local/tomcat/export catalina_home =/usr/local/tomcat/export catalina_tmpdir =/usr/local/tomcat/temp export jre_home =/usr/Java/jdk1.7.0 _ 55/
# Tomcat self-start
/Usr/local/tomcat/bin/startup. Sh start
Touch/var/lock/subsys/local -- if this sentence exists in the document, you do not need to write it again.

2. Add the prepared STARTUP script to the/etc/rc. d/init. d/directory, and run the command chkconfig to set the startup. (Recommended)

Chkconfig Function Description: Check and set various services of the system.

Syntax: chkconfig [-- add] [-- del] [-- list] [System Service] Or chkconfig [-- level <level code>] [System Service] [ON/OFF/Reset]

-- Add Add add service

-- Del Delete Service

-- List to view the startup status of each Service

Set redis auto-start in eg1.

To start redis, you need to run the redis-server and redis. conf files.

Script: Vim/etc/init. d/redis

Vim/etc/init. d/redis
# Chkconfig: 2345 10 90 # Description: Start and Stop redis Path =/usr/local/bin:/sbin:/usr/bin: /bin redisport = 6379 # exec =/usr/local/redis/src/redis-server # redis_cli =/usr/local/redis/src/ redis-cli # The actual environment depends on pidfile =/var/run/redis. pidconf = "/usr/local/redis. conf "# actual environment depends on Case" $1 "in START) If [-F $ pidfile] Then ECHO" $ pidfile exists, process is already running or crashed. "Else echo "Starting redis server..." $ exec $ conf Fi if ["$? "=" 0 "] Then ECHO" redis is running... "fi; stop) If [! -F $ pidfile] Then ECHO "$ pidfile exists, process is not running. "Else pid = $ (cat $ pidfile) echo" stopping... "$ redis_cli-p $ redisport shutdown while [-x $ (pidfile)] Do echo" waiting for redis to shutdown... "Sleep 1 done echo" redis stopped "fi; restart | force-Reload) $ {0} Stop $ {0} start; *) echo" Usage: /etc/init. d/redis {START | stop | restart | force-Reload} "> & 2 exit 1 esac

# Modifying permissions and owner

chown root.root  /etc/rc.d/init.d/redischmod  755 /etc/rc.d/init.d/redis

# Put redis into the cenos startup management system

chkconfig --add redis

# Set auto-start upon startup

chkconfig redis on

# Test redis startup

redis-cli redis 127.0.0.1:6379> set foo 123OKredis 127.0.0.1:6379> get foo"123"redis 127.0.0.1:6379> exit

Eg2.fastdfs auto-start

[[email protected] ~]# cp /usr/local/src/FastDFS/init.d/fdfs_storaged /etc/init.d/[[email protected] ~]# chkconfig --add fdfs_storaged[[email protected] ~]# chkconfig fdfs_storaged on[[email protected] ~]# service fdfs_storaged start

############################## Use the chkconfig command to set Tomcat for Automatic startup ############################

1. Modify the start. Sh file.

Vim/home/wwwroot/tomcat_wiki/bin/startup. Sh

Add the following content to the file header:

#! /Bin/sh

# Chkconfig: 2345 97 00 # Description: Tomcat auto start # processname: Tomcat

2. Modify the Catalina. Sh file.

Vim/home/wwwroot/tomcat_wiki/bin/Catalina. Sh

Add the following content:

Export export =/home/wwwroot/tomcat_wiki export catalina_home =/home/wwwroot/tomcat_wiki export =/home/wwwroot/tomcat_wiki/temp export jre_home =/usr/local/jdk1.6.0

3. Create a link file

Ln-S/home/wwwroot/tomcat_wiki/bin/startup. sh/etc/init. d/tomcat

4. Modify permissions

Chmod + x Tomcat

5. Add startup

Chkconfig-add Tomcat (two minus signs before "add)

Chkconfig Tomcat on

6. Check

Service Tomcat start

Or reboot

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.