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

教程开始

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
相关推荐
chian-ocean18 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=19 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
橘子味的茶二29 分钟前
高级系统架构师--第十章:计算机网络
服务器·计算机网络·系统架构
紫菜(Nori)1 小时前
短连接服务器压测-wrk
服务器·压力测试
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
北京耐用通信1 小时前
航空装配自动化神器Ethercat转profient网关搭配机器人精准控制
运维·机器人·自动化
吃汤圆的抹香鲸1 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
崔lc4 小时前
linux中安装部署Jenkins,成功构建springboot项目详细教程
运维·jenkins
luojiaao4 小时前
【Jenkins】个人向-Jenkinsfile如何写
运维·jenkins