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

教程开始

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
相关推荐
马立杰3 小时前
H3CNE-33-BGP
运维·网络·h3cne
云空4 小时前
《DeepSeek 网页/API 性能异常(DeepSeek Web/API Degraded Performance):网络安全日志》
运维·人工智能·web安全·网络安全·开源·网络攻击模型·安全威胁分析
没有名字的小羊5 小时前
Cyber Security 101-Build Your Cyber Security Career-Security Principles(安全原则)
运维·网络·安全
m0_465215795 小时前
TCP & UDP Service Model
服务器·网络·tcp/ip
千夜啊5 小时前
Nginx 运维开发高频面试题详解
运维·nginx·运维开发
存储服务专家StorageExpert6 小时前
答疑解惑:如何监控EMC unity存储系统磁盘重构rebuild进度
运维·unity·存储维护·emc存储
chian-ocean8 小时前
从理论到实践:Linux 进程替换与 exec 系列函数
linux·运维·服务器
敖行客 Allthinker8 小时前
从 UTC 日期时间字符串获取 Unix 时间戳:C 和 C++ 中的挑战与解决方案
linux·运维·服务器·c++
JunLan~8 小时前
Docker 部署 GLPI(IT 资产管理软件系统)
运维·docker·容器
norsd10 小时前
MongoDb user自定义 role 添加 action(collStats, EstimateDocumentCount)
服务器·数据库·mongodb