1.根据情况填写对应变量
vim man-redis
#!/bin/bashinstall_dir=/usr/localserver_dir=redislog_dir=/var/logport=6379if [[ "$1" == "start" ]];then netstat -unltp |grep :${port} &> /dev/nullif [ $? -eq 0 ];then echo "redis Already started" exit fi nohup ${install_dir}/${server_dir}/bin/redis-server ${install_dir}/${server_dir} &> ${log_dir}/${server_dir}/redis.log &elif [[ "$1" == "stop" ]];then netstat -unltp |grep :${port} &> /dev/nullif [ $? -eq 0 ];then pid=`netstat -unltp | grep :${port} | head -1 |awk '{print $7}' | awk -F'/' '{print $1}'` kill -9 $pid fielse echo "start | stop"fi2.添加权限,并加入到bin目录下,后面就可以当命令一样使用
mv man-redis /usr/local/bin
chmod +x /usr/local/bin/man-redis
man-redis start
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。