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

教程开始

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
相关推荐
指尖@韶华14 小时前
【Kylin Linux root 密码故障处置指南(超限重试 + 改回原密码)】
linux·运维·kylin
Madison-No714 小时前
【Linux】 第一个系统程序——进度条
linux·运维·服务器
求你别吃了ど⁰̷̴͈꒨⁰̷̴͈う♡14 小时前
Linux给命令起别名
linux·运维·服务器
王火火(DDoS CC防护)14 小时前
如何判断服务器是否遭受攻击?
服务器·web安全·网络安全·ddos攻击
年度最佳学生14 小时前
【linux】解决selinux 导致的 systemctl code=exited, status=203/EXEC
linux·运维·服务器
青山的青衫14 小时前
【用homebrew配置nginx+配置前端项目与后端联调】Macbook M1(附一些homebrew操作)
运维·前端·nginx
Maple_land14 小时前
内建命令揭秘与环境变量全景:Linux变量体系的完整闭环
linux·运维·服务器·c++·centos
D11_15 小时前
阿里云服务器百度站长平台验证完整指南:SSH文件验证详解
服务器·百度·阿里云
EndingCoder15 小时前
Node.js 数据查询优化技巧
服务器·javascript·数据库·node.js·数据查询优化
程序员老赵15 小时前
Docker 部署银河麒麟(Kylin Linux)全流程教程
运维·docker