systemd-run.md 1.6 KB

systemd-run

ํ”„๋กœ๊ทธ๋žจ์„ ์ผ์‹œ์  ๋ฒ”์œ„ ๋‹จ์œ„, ์„œ๋น„์Šค ๋‹จ์œ„, ๊ฒฝ๋กœ, ์†Œ์ผ“ ๋˜๋Š” ํƒ€์ด๋จธ๋กœ ํŠธ๋ฆฌ๊ฑฐ๋œ ์„œ๋น„์Šค ๋‹จ์œ„๋กœ ์‹คํ–‰. ๋” ๋งŽ์€ ์ •๋ณด: https://www.freedesktop.org/software/systemd/man/systemd-run.html.

  • ์ผ์‹œ์  ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘:

sudo systemd-run {{๋ช…๋ น์–ด}} {{์ธ์ˆ˜1 ์ธ์ˆ˜2 ...}}

  • ํ˜„์žฌ ์‚ฌ์šฉ์ž์˜ ์„œ๋น„์Šค ๊ด€๋ฆฌ์ž์—์„œ (๊ถŒํ•œ ์—†์ด) ์ผ์‹œ์  ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘:

systemd-run --user {{๋ช…๋ น์–ด}} {{์ธ์ˆ˜1 ์ธ์ˆ˜2 ...}}

  • ์‚ฌ์šฉ์ž ์ •์˜ ๋‹จ์œ„ ์ด๋ฆ„๊ณผ ์„ค๋ช…์„ ์‚ฌ์šฉํ•˜์—ฌ ์ผ์‹œ์  ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘:

sudo systemd-run --unit={{์ด๋ฆ„}} --description={{๋ฌธ์ž์—ด}} {{๋ช…๋ น์–ด}} {{์ธ์ˆ˜1 ์ธ์ˆ˜2 ...}}

  • ์ข…๋ฃŒ ํ›„ ์ •๋ฆฌ๋˜์ง€ ์•Š๋Š” ์ผ์‹œ์  ์„œ๋น„์Šค์™€ ์‚ฌ์šฉ์ž ์ •์˜ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‹œ์ž‘:

sudo systemd-run --remain-after-exit --set-env={{์ด๋ฆ„}}={{๊ฐ’}} {{๋ช…๋ น์–ด}} {{์ธ์ˆ˜1 ์ธ์ˆ˜2 ...}}

  • ์ฃผ๊ธฐ์ ์œผ๋กœ ์ผ์‹œ์  ์„œ๋น„์Šค๋ฅผ ์‹คํ–‰ํ•˜๋Š” ์ผ์‹œ์  ํƒ€์ด๋จธ ์‹œ์ž‘ (์บ˜๋ฆฐ๋” ์ด๋ฒคํŠธ ํ˜•์‹์€ man systemd.time ์ฐธ์กฐ):

sudo systemd-run --on-calendar={{์บ˜๋ฆฐ๋”_์ด๋ฒคํŠธ}} {{๋ช…๋ น์–ด}} {{์ธ์ˆ˜1 ์ธ์ˆ˜2 ...}}

  • ํ„ฐ๋ฏธ๋„์„ ํ”„๋กœ๊ทธ๋žจ๊ณผ ๊ณต์œ ํ•˜์—ฌ ์ƒํ˜ธ์ž‘์šฉ ์ž…๋ ฅ/์ถœ๋ ฅ์„ ํ—ˆ์šฉํ•˜๊ณ  ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ ํ›„ ์‹คํ–‰ ์„ธ๋ถ€์ •๋ณด๋ฅผ ์œ ์ง€:

systemd-run --remain-after-exit --pty {{๋ช…๋ น์–ด}}

  • ํ”„๋กœ์„ธ์Šค์˜ ์†์„ฑ (์˜ˆ: CPUQuota, MemoryMax)์„ ์„ค์ •ํ•˜๊ณ  ์ข…๋ฃŒ๋  ๋•Œ๊นŒ์ง€ ๋Œ€๊ธฐ:

systemd-run --property MemoryMax={{๋ฉ”๋ชจ๋ฆฌ_๋ฐ”์ดํŠธ}} --property CPUQuota={{CPU_์‹œ๊ฐ„_๋น„์œจ}}% --wait {{๋ช…๋ น์–ด}}

  • ์…ธ ํŒŒ์ดํ”„๋ผ์ธ์—์„œ ํ”„๋กœ๊ทธ๋žจ ์‚ฌ์šฉ:

{{๋ช…๋ น์–ด1}} | systemd-run --pipe {{๋ช…๋ น์–ด2}} | {{๋ช…๋ น์–ด3}}