Ubuntu关闭开机自启项

Ubuntu关闭开机自启项

很多时候服务器重启速度越来越慢,cpu占用率越来越高,很大原因是服务器里面有很多开机自启项,需要手动查询出来并禁用!

 

首先用以下命令显示出开启的和未开启的程序:

systemctl list-unit-files

 

 

使用grep过滤一下开启的

systemctl list-unit-files |grep enabled

 

 

 

 

 

先停止已经开启的服务:

sudo systemctl stop mongodb.service
sudo systemctl stop nginx.service
sudo systemctl stop redis-server.service

 

然后禁用开机启动:

sudo systemctl disable mongodb.service
sudo systemctl disable nginx.service
sudo systemctl disable redis-server.service

 

可以用shell脚本的for循环来批量操作

 

posted @ 2021-02-22 19:05  小海之家  阅读(4794)  评论(0编辑  收藏  举报