服务器需要扩容,如何停止宝塔的所有服务?

教程开始

1:新建一个shell脚本执行以下代码

或者进面板 把以下代码丢到计划任务里的shell脚本执行

shell 复制代码
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
stop_service(){
        /etc/init.d/bt stop
        if [ -f "/etc/init.d/nginx" ]; then
                /etc/init.d/nginx stop > /dev/null 2>&1
        fi
        if [ -f "/etc/init.d/httpd" ]; then
                /etc/init.d/httpd stop > /dev/null 2>&1
        fi
        if [ -f "/etc/init.d/mysqld" ]; then
                /etc/init.d/mysqld stop > /dev/null 2>&1
        fi
        if [ -f "/etc/init.d/pure-ftpd" ]; then
                /etc/init.d/pure-ftpd stop > /dev/null 2>&1
        fi
        if [ -f "/etc/init.d/tomcat" ]; then
                /etc/init.d/tomcat stop > /dev/null 2>&1
        fi
        if [ -f "/etc/init.d/redis" ]; then
                /etc/init.d/redis stop > /dev/null 2>&1
        fi
        if [ -f "/etc/init.d/memcached" ]; then
                /etc/init.d/memcached stop > /dev/null 2>&1
        fi
        if [ -f "/www/server/panel/data/502Task.pl" ]; then
                rm -f /www/server/panel/data/502Task.pl
                if [ -f "/etc/init.d/php-fpm-52" ]; then
                        /etc/init.d/php-fpm-52 stop > /dev/null 2>&1
                fi
                if [ -f "/etc/init.d/php-fpm-53" ]; then
                        /etc/init.d/php-fpm-53 stop > /dev/null 2>&1
                fi
                if [ -f "/etc/init.d/php-fpm-54" ]; then
                        /etc/init.d/php-fpm-54 stop > /dev/null 2>&1
                fi
                if [ -f "/etc/init.d/php-fpm-55" ]; then
                        /etc/init.d/php-fpm-55 stop > /dev/null 2>&1
                fi
                if [ -f "/etc/init.d/php-fpm-56" ]; then
                        /etc/init.d/php-fpm-56 stop > /dev/null 2>&1
                fi
                if [ -f "/etc/init.d/php-fpm-70" ]; then
                        /etc/init.d/php-fpm-70 stop > /dev/null 2>&1
                fi
                if [ -f "/etc/init.d/php-fpm-71" ]; then
                        /etc/init.d/php-fpm-71 stop > /dev/null 2>&1
                fi
        fi
        swapoff /www/swap
}
stop_service

2:执行完后扩容好磁盘后重新挂载上去后执行以下两条命令

shell 复制代码
swapon /www/swap
echo "True" > /www/server/panel/data/502Task.pl

3:最后别忘了启动宝塔服务哦

shell 复制代码
/etc/init.d/bt start
相关推荐
小小菜鸡ing2 小时前
pymysql
java·服务器·数据库
Mr. Cao code3 小时前
Docker:颠覆传统虚拟化的轻量级革命
linux·运维·ubuntu·docker·容器
wanhengidc4 小时前
云手机运行流畅,秒开不卡顿
运维·网络·科技·游戏·智能手机
笨小孩@GF 知行合一4 小时前
OSPF实验:外部路由引入
运维·网络·hcip·数通·ospf
asdfg12589635 小时前
为什么要在出口路由器router配置NAT与默认路由
运维·网络·计算机网络
当归10245 小时前
SQL Server死锁排查实战指南
java·服务器·网络
bug攻城狮5 小时前
Skopeo 工具介绍与 CentOS 7 安装指南
linux·运维·centos
宇宙第一小趴菜5 小时前
08 修改自己的Centos的软件源
linux·运维·centos
qinyia5 小时前
用 Wisdom SSH 轻松实现服务器自动化任务调度
服务器·自动化·ssh
bug攻城狮5 小时前
彻底禁用 CentOS 7.9 中 vi/vim 的滴滴声
linux·运维·服务器·centos·vim