service 명령이 서비스 파일을 인식하지 못합니다. RHEL6.9

service 명령이 서비스 파일을 인식하지 못합니다. RHEL6.9

나는 사용 중이며 내 서비스 파일을 폴더 와 폴더 rhel6.9에 모두 복사했습니다 . 이전에 서비스를 설정한 적은 있지만 , oldschool 명령어로는 시도해 본 적이 없습니다 ./etc/systemd/system/usr/lib/systemd/system/systemctlservice

이제 service mytest start작동하지 않습니다. 인식할 수 없는 서비스라고 나옵니다. 당신 은 systemctl을 실행합니다 daemon-reload. 그런데 로 어떻게 해야 합니까 service?

답변1

service
다양한 Unix 및 Linux에서 서비스 시작, 다시 시작, 중지 및 상태 서비스에 사용되는 "상위 수준" 명령입니다 . "하위 수준" 서비스 관리자에 따라 서비스는 다른 바이너리로 리디렉션됩니다.

예를 들어 CentOS 7에서는 로 리디렉션되는 systemctl반면 CentOS 6에서는 상대 /etc/init.d스크립트를 직접 호출합니다. 반면, 이전 Ubuntu 릴리스에서는 시작으로 리디렉션됩니다.

서비스는 기본 서비스 관리에 적합하며, 직접 호출하면 systemctl 더 많은 제어 옵션이 제공됩니다.

RHEL6에서는 먼저 서비스를 추가합니다.

chkconfig --add SERVICE

그런 다음 활성화하거나 비활성화하려면 다음을 수행하십시오.

chkconfig SERVICE on
chkconfig SERVICE off

서비스가 활성화되어 있는지 확인하십시오.

chkconfig SERVICE --list 

RHEL7 이상에서는 다음 부팅이나 기타 트리거 시 시작하기 위해 다음과 같이 서비스를 켤 수도 있습니다.

systemctl enable SERVICE

의 모든 최신 버전은 systemctl중단된 경우 ".service"를 가정합니다.

/etc/systemd/system/lircmd.service

다음과 같이 됩니다:

systemctl enable lircmd

또한 Systemd사용했던 모든 작업을 하나의 명령으로 가져오므 chkconfigservice일반적 systemctl으로 장기적으로 대처하기가 더 쉽습니다.

다음도 참조하세요 man update-rc.d.

update-rc.d 모든 스크립트 의 스크립트 LSB 주석 헤더 에 종속성과 runlevel정보가 제공되어야 합니다.init.dinit.d

여기처럼:

스크립트 에 다음과 같은 블록을 추가합니다 init.d.

### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

https://wiki.debian.org/LSBInitScripts


service 명령은 시스템 관리자가 init사용 중인 실제 시스템에 대해 크게 걱정하지 않고 서비스의 상태를 시작, 중지 및 확인할 수 있도록 하는 래퍼 스크립트입니다. systemd가 도입되기 전에는 /etc/init.d스크립트와 Upstart의 명령 에 대한 래퍼였지만 initctl이제는 이 두 가지와 systemctl에 대한 래퍼이기도 합니다.

man service:

service(8)                                                                                              System Manager's Manual                                                                                              service(8)

NAME
       service - run a System V init script

SYNOPSIS
       service SCRIPT COMMAND [OPTIONS]

       service --status-all

       service --help | -h | --version

DESCRIPTION
       service runs a System V init script, systemd unit, or upstart job in as predictable an environment as possible, removing most environment variables and with the current working directory set to /.

       The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT, or the name of a systemd unit, or the name of an upstart job in /etc/init. The existence of a systemd unit or upstart job of the same name
       as a script in /etc/init.d will cause the unit/job to take precedence over the init.d script.  The supported values of COMMAND depend on the invoked script.  service passes COMMAND and OPTIONS to the init script  unmodified.
       For  systemd  units  or upstart jobs, start, stop, status, and reload are passed through to their systemctl/initctl equivalents. For upstart jobs, restart will call the upstart 'stop' for the job, followed immediately by the
       'start', and will exit with the return code of the start command.

       All scripts should support at least the start and stop commands.  As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start command. This option has no  effect
       on upstart jobs.

       service  --status-all  runs  all  init  scripts,  in alphabetical order, with the status command.  The status is [ + ] for running services, [ - ] for stopped services and [ ? ] for services without a 'status' command.  This
       option only calls status for sysvinit jobs; upstart jobs can be queried in a similar manner with initctl list.

EXIT CODES
       service calls the init script and returns the status returned by it.

FILES
       /etc/init.d
              The directory containing System V init scripts.

       /etc/init
              The directory containing upstart jobs.

       /{lib,run,etc}/systemd/system
              The directories containing systemd units.

ENVIRONMENT
       LANG, LANGUAGE, LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, LC_IDENTIFICATION, LC_ALL, TERM, PATH
              The only environment variables passed to the init scripts.

SEE ALSO
       /etc/init.d/skeleton,
       update-rc.d(8),
       init(8),
       invoke-rc.d(8).
       systemctl(1).
       initctl(8).

또한보십시오:

관리 서비스-사용-systemd-and-systemctl-in-linux/

출처:

https://askubuntu.com/questions/903354/difference-between-systemctl-and-service-commands

https://stackoverflow.com/questions/43537851/difference-between-systemctl-and-service-command

http://www.safdar.com/how-to/linux-services-systemctl-systemd-vs-service-sysvinit.html

서비스 대 systemctl 스크립트 - 사용할 스크립트

https://wiki.debian.org/LSBInitScripts

https://access.redhat.com/articles/1189123

관련 정보