One-click Add and start Redis other port scripts in Linux

Source: Internet
Author: User
Tags redis

One-click Add and start Redis other ports are as follows

#!/bin/bash

Set--' getopt d:p:h $* '
Getopt_rc=$?
If ["$getopt _rc"-ne "0"]; Then
Pgm= ' basename $ '
echo "$PGM $getopt _rc Process failed during getopt attempt-illegal parameters"
Exit 10
Fi
While [$#-GT 0]; Todo
Case is in
-P)
Shift
New_port=$1
Shift
;;
--)
Shift
Break
Esac

Done

If [-Z "$NEW _port"]; Then
echo "-p [port] must input"
Exit
Fi

Config_dir= '/etc '
config= "$CONFIG _dir"/redis. " $NEW _port ". conf
replace_port= "50{s/6379/$NEW _port/}" # Replaces line 50th only
Replace_db= "182{s/dump.rdb/dump. $NEW _port.rdb/}" # Replaces line 182th only

CP $CONFIG _dir/redis.conf $CONFIG && sed-i-e $REPLACE _port $CONFIG && sed-i-e $REPLACE _db $CONFIG
/usr/local/bin/redis-server $CONFIG
Note:
Use the SED command to replace only one row.
Save As Add_redis_port.sh, using the method:
chmod +x./add_redis_port.sh
./add_redis_port.sh-p 6588

Related Article

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.