启动时并行启动服务

启动时并行启动服务

由于服务太多,我的启动有点慢。服务列表如下(输出sudo ls -l /etc/rc$(sudo runlevel| awk '{print $2}').d):

lrwxrwxrwx 1 root root 18 Mar 21  2020 K01whoopsie -> ../init.d/whoopsie
lrwxrwxrwx 1 root root 15 Mar 21  2020 S01acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root 17 Mar 21  2020 S01anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root 16 Mar 21  2020 S01apport -> ../init.d/apport
lrwxrwxrwx 1 root root 22 Mar 21  2020 S01avahi-daemon -> ../init.d/avahi-daemon
lrwxrwxrwx 1 root root 19 Mar 21  2020 S01bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root 26 Mar 21  2020 S01console-setup.sh -> ../init.d/console-setup.sh
lrwxrwxrwx 1 root root 14 Mar 21  2020 S01cron -> ../init.d/cron
lrwxrwxrwx 1 root root 14 Mar 21  2020 S01cups -> ../init.d/cups
lrwxrwxrwx 1 root root 22 Mar 21  2020 S01cups-browsed -> ../init.d/cups-browsed
lrwxrwxrwx 1 root root 14 Mar 21  2020 S01dbus -> ../init.d/dbus
lrwxrwxrwx 1 root root 16 Dec 31 23:43 S01docker -> ../init.d/docker
lrwxrwxrwx 1 root root 14 Mar 21  2020 S01gdm3 -> ../init.d/gdm3
lrwxrwxrwx 1 root root 21 Mar 21  2020 S01grub-common -> ../init.d/grub-common
lrwxrwxrwx 1 root root 20 Mar 21  2020 S01irqbalance -> ../init.d/irqbalance
lrwxrwxrwx 1 root root 20 Mar 21  2020 S01kerneloops -> ../init.d/kerneloops
lrwxrwxrwx 1 root root 14 Dec  9 21:21 S01nmbd -> ../init.d/nmbd
lrwxrwxrwx 1 root root 17 Dec 12 22:31 S01openvpn -> ../init.d/openvpn
lrwxrwxrwx 1 root root 18 Mar 21  2020 S01plymouth -> ../init.d/plymouth
lrwxrwxrwx 1 root root 17 May  6 20:56 S01postfix -> ../init.d/postfix
lrwxrwxrwx 1 root root 15 Mar 21  2020 S01rsync -> ../init.d/rsync
lrwxrwxrwx 1 root root 17 Mar 21  2020 S01rsyslog -> ../init.d/rsyslog
lrwxrwxrwx 1 root root 21 Dec  9 21:21 S01samba-ad-dc -> ../init.d/samba-ad-dc
lrwxrwxrwx 1 root root 15 Mar 21  2020 S01saned -> ../init.d/saned
lrwxrwxrwx 1 root root 23 May  6 20:56 S01smartmontools -> ../init.d/smartmontools
lrwxrwxrwx 1 root root 14 Dec  9 21:21 S01smbd -> ../init.d/smbd
lrwxrwxrwx 1 root root 27 Mar 21  2020 S01speech-dispatcher -> ../init.d/speech-dispatcher
lrwxrwxrwx 1 root root 23 Mar 21  2020 S01spice-vdagent -> ../init.d/spice-vdagent
lrwxrwxrwx 1 root root 13 Dec  9 21:15 S01ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root 18 Dec 12 23:22 S01stunnel4 -> ../init.d/stunnel4
lrwxrwxrwx 1 root root 29 Mar 21  2020 S01unattended-upgrades -> ../init.d/unattended-upgrades
lrwxrwxrwx 1 root root 15 Mar 21  2020 S01uuidd -> ../init.d/uuidd
lrwxrwxrwx 1 root root 24 Dec 12 23:22 S01windscribe-cli -> ../init.d/windscribe-cli

我想让这些服务在启动时并行启动,我认为这段代码可以完成同一级别服务并行执行的任务:

for i in /etc/rc$runlevel.d/S*
do
 case "$runlevel" in
  0|6) startup $i stop ;;
  *) startup $i start ;;
 esac
done

但问题是我不知道应该把这段代码放在哪里。我甚至找不到 /etc/init.d/rc 脚本

相关内容