Debian - установка rc.local: различия между версиями

Материал из support.qbpro.ru
imported>Vix
(Новая страница: « == Установка службы авто-запуска в системе rc.local == * Создаем файл: /etc/rc.local :>/etc/rc.local * Содер…»)
 
Строка 25: Строка 25:


* Содержимое:
* Содержимое:
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
  [Unit]
  [Unit]
  Description=/etc/rc.local Compatibility
Description=/etc/rc.local Compatibility
  ConditionPathExists=/etc/rc.local
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target
   
   
  [Service]
  [Service]
  Type=forking
Type=forking
  ExecStart=/etc/rc.local start
ExecStart=/etc/rc.local start
  TimeoutSec=0
TimeoutSec=0
  StandardOutput=tty
RemainAfterExit=yes
  RemainAfterExit=yes
GuessMainPID=no
  SysVStartPriority=99
   
   
[Install]
  WantedBy=multi-user.target
* Даем права на запуск: /etc/rc.local
* Даем права на запуск: /etc/rc.local
  chmod +x /etc/rc.local
  chmod +x /etc/rc.local

Версия от 19:51, 16 ноября 2023

Установка службы авто-запуска в системе rc.local

  • Создаем файл: /etc/rc.local
:>/etc/rc.local
  • Содержимое:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
 
exit 0
  • Создаем файл: /etc/systemd/system/rc-local.service
:>/etc/systemd/system/rc-local.service
  • Содержимое:
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

  • Даем права на запуск: /etc/rc.local
chmod +x /etc/rc.local
  • Включаем сервис rc-local:
systemctl enable rc-local
systemctl start rc-local.service
  • Проверяем работу:
systemctl status rc-local.service
  • Вывод правильный:
● rc-local.service - /etc/rc.local Compatibility
  Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset:
 Drop-In: /lib/systemd/system/rc-local.service.d
          └─debian.conf
  Active: active (exited) since Tue 2017-07-25 11:10:09 EEST; 7s ago
 Process: 1148 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

Июл 25 11:10:09 webserver systemd[1]: Starting /etc/rc.local Compatibility...
Июл 25 11:10:09 webserver systemd[1]: Started /etc/rc.local Compatibility.

Ресурсы: