Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux streamlines the script for booting self-starting service

Shulou Source: shulou.com Published: 2022-06-02 07:59:53 11月06日 Update

After the operating system starts, some services and programs will be started automatically. Some of these programs are not necessary for the server to function properly.

For the server, running redundant services and programs will not add points to the server, but will bring other hidden dangers:

1. Resource consumption: every time you run an extra service, you take up an extra share of the resource.

two。 Bring security vulnerabilities: every service may have vulnerabilities or potential vulnerabilities. Extra services will increase maintenance costs.

Therefore, it is very necessary to simplify the server self-booting program. For newly installed servers, you can use scripts to streamline services directly, and then deploy the required services. But for a running server, you need to make a judgment when simplifying! Otherwise, after streamlining and restarting, some necessary service processes will not be started automatically, and the restart will directly affect the business.

The following is a simplified script, which shuts down all self-starting services before starting the following services:

Crond: scheduling tasks

Network: network service, control and enable network card

Rsyslog/syslog: operating system log service

Ssh: ssh remote service

Systat: server performance monitoring tool

Iptables: firewall service

Udev-post: dynamic device management

#! / bin/bash# Author:cubix# Date:2017-05-1 roomVersion: 1.such Description:Set mini service for system boot.LANG=en## Stop all services which is auto start on system boot.for SERVICE in `chkconfig-- list | grep "3:on" | awk'{print $1} '`do chkconfig $SERVICE off done # # Set auto start services on system boot.for AUTOSTART in `chkconfig-- list | grep-E' crond | network | rsyslog | syslog | ssh | iptables | udev-post' | awk'{print $1} '`do chkconfig $AUTOSTART-level 345 on done

Tags: Services servers programs runs scripts vulnerabilities essentials operating systems systems resources security business tasks dynamic security vulnerabilities tools performance costs logs Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple Shulou Technology Shulou Information macOS