Set redis startup in ubuntu

Source: Internet
Author: User
Ubuntu sets redis to start from startup. Today, we are so angry that we are sorry for starting redis. For me, this is not a small job, if you want to fully understand it. The difficulty is as follows: www.2cto. com1 --- redis startup script and shell script writing. 2 --- linux server... ubuntu sets up redis to start from startup. Today, we are so angry that we are sorry for starting redis. For me, this is not a small job, if you want to fully understand it. Difficulties: www.2cto.com 1 --- redis startup script and shell script writing. 2 --- linux service mechanism, how do the processes start and shut down. There are also some difficulties. Fortunately, today's status is good and all of them have been solved one by one. Therefore, the flow records are as follows. The following is the script for starting www.2cto.com, which is also a reference for others. [Cpp] #! /Bin/sh server_dir =/opt/redis-2.6.10 server_name = redis-server demo = $ server_dir/src/$ server_name configuration_file = $ server_dir/redis. conf pid_file = $ server_dir/pid/redis. pid start () {# check whether the server exists and has the execution permission if test-x $ demo echo "Starting redis" then # run the startup command, return execution result if $ demo $ configuration_file then echo "OK" else echo "Failed" fi else echo "cocould not find redis server ($ demo)" fi} stop () {# check if the pid file is No. if yes, it indicates that if test-e $ pid_file then echo "Stopping redis" # only the process ID is stored in the pid file, if kill 'cat $ pid_file 'then echo "OK" else echo "Failed" fi else echo "No server is running! "Exit 0 fi} restart () {stop start} # Check the input command case $1 in start) start; stop) stop; restart | reload) restart ;;*) echo "Bad command" exit 1 esac exit 0 problems: 1 -- use of shell case 2 -- use of shell test command 3 -- shell space (value assignment/judgment) if the script passes the test, you can perform the next task: Set the script to start and run at startup.

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.