linux关闭http服务的命令,一条命令启动一个http 服务器,不需要安装任何软件

这里写成了一个脚本启动方式方便更改 端口 根目录 一起启动关闭

#config 如果想改变端口跟根目录直接修改即可 切记先停止服务在进行修改

#default port is 20000

#port=20000

#default root is /tmp

#dir_root=/tmp

vi  lrm_http

#!/bin/bash

#

# - this script starts and stops the lrm daemon

#

#

#config

# default port is 20000

port=20000

#default  root is /tmp

dir_root=/tmp

start() {

echo -e $"Starting : lrm_http  \033[32m ok \033[0m "

pushd $dir_root >/dev/null

nohup  python -m SimpleHTTPServer "$port" > /tmp/lrm_http_log 2>&1  &

}

stop() {

pIDa=`/usr/sbin/lsof -i :"$port"|grep -v "PID" | awk '{print $2}'`

if [ "$pIDa" != "" ];

then

echo -e $"Stopping  lrm_http"

kill -9  $(ss -n -t -l -p | grep "$port" | column -t | awk -F ',' '{print $(NF-1)}')

else

echo "lrm_http services is not start "

fi

}

restart() {

stop

sleep 1

start

}

case "$1" in

start)

$1

;;

stop)

$1

;;

restart)

$1

;;

*)

echo $"Usage: $0 {start|stop|restart}"

exit 2

esac

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值