Systemd Service - swkim0128/PARA GitHub Wiki

Systemd Service

rw-book-cover

Metadata

  • Author: velog.io
  • Full Title: Systemd Service
  • Category: #articles
  • Document Tags: linux
  • Summary: The text explains how to create and manage systemd services, using ssh.service as an example. It covers key sections like [Unit], [Service], and [Install], detailing their purposes and configurations. Additionally, it illustrates how to enable and start services while explaining dependencies and service types.
  • URL: https://velog.io/@markyang92/systemd-timer

Highlights

  • μ„œλΉ„μŠ€ μ†Œμ† Target Unitμ„€μ • 및 λΆ€νŒ… μ‹œ Unit이 enable, disable 을 μœ„ν•œ μ„Ήμ…˜ (View Highlight)
    • Note: [install] μ„Ήμ…˜ κ΄€λ ¨ μ„€λͺ…
  • WantedBy : Unit이 μ–΄λ–»κ²Œ ν™œμ„±ν™”(enable)될 것인지에 λŒ€ν•œ λΆ€λΆ„ (View Highlight)
    • Note: Install μ„Ήμ…˜, WantedBy μ„€μ • μ„€λͺ…
  • $ sudo systemctl enable λͺ…λ Ήμ–΄λ‘œ Unit을 enableν•  λ•Œ, 등둝에 ν•„μš”ν•œ μœ λ‹›μ„ μ§€μ •ν•œλ‹€. β€’ Dependency Check라 생각 β€’ **/etc/systemd/system/μ§€λͺ….target.wants**에 λ“€μ–΄κ°„λ‹€. β€’ λΆ€νŒ… μ‹œ, μ†ν•œ .wants에 따라 μ‹€ν–‰λ˜κ²Œν•œλ‹€. (View Highlight)
    • Note: Install μ„Ήμ…˜, WantedBy μ„€μ • μ„€λͺ… 2
  • μ‹€μ œ ssh.service의 μœ„μΉ˜: /usr/lib/systemd/system/ssh.service (View Highlight)
    • Note: multi-user.target으둜 μ„€μ •ν•  경우, λ“±λ‘λ˜λŠ” μœ„μΉ˜
  • 3-1. /etc/systemd/system/multi-user.target.wants/에 ssh.service μ†Œν”„νŠΈλ§ν¬ 생성 3-2. /etc/systemd/system/에 systemdκ°€ μ•Œμ•„λ¨Ήμ„ 수 있게, Alias=sshd.serviceλŒ€λ‘œ sshd.service κ°€ μƒμ„±λ˜μ–΄, sshdλΌλŠ” μ΄λ¦„μœΌλ‘œλ„ μ ‘κ·Ό ν•  수 μžˆλŠ” κ²ƒμž„ (View Highlight)
    • Note: μ‹€μ œ μƒμ„±μœ„μΉ˜ : /usr/lib/systemd/system/ μ†Œν”„νŠΈλ§ν¬ μƒμ„±μœ„μΉ˜ : /etc/systemd/system/multi-user.tartget.wants Alias 링크 μƒμ„±μœ„μΉ˜ : /etc/systemd/system
  • Alias β€’ [Install] β€’ Alias: Unit alias 이름 μ§€μ • β€’ $ sudo systemctl enable 'alias' μ ‘κ·Ό κ°€λŠ₯ β€’ alias 이름은 Unit 파일 ν™•μž₯자λ₯Ό κ°€μ§€κ³  μžˆμ–΄μ•Όν•œλ‹€. β€’ service, socket, mount, swap λ“±. β€’ e.g. β€’ μ„œλΉ„μŠ€ 이름: httpd.serviceμ‹œ, Alias=[Alias Name].service (View Highlight)
⚠️ **GitHub.com Fallback** ⚠️