wiki/_next/data/Ie9t5zutrXP6Of75Cb5xF/linux.systemd.services.json

1 line
11 KiB
JSON
Raw Normal View History

2022-07-29 15:41:17 +00:00
{"pageProps":{"metadata":{"date":"2021-07-19 21:46:52 +08:00","date_modified":"2021-08-02 11:56:12 +08:00","language":"en","source":""},"title":"systemd services","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"service-management-basics"},"children":[{"type":"text","value":"Service management basics"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/linux.systemd.services#service-management-basics"},"children":[{"type":"text","value":"Service management basics"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"service-configuration"},"children":[{"type":"text","value":"Service configuration"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/linux.systemd.services#service-configuration"},"children":[{"type":"text","value":"Service configuration"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One of the functions of the system suite is service management.\nLike most of the components, it can be used at user-level with their set locations, managing the service daemon, and all.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"service-management-basics"},"children":[{"type":"text","value":"Service management basics"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Just plop down a service unit file at one of the search paths and you can start managing right away.\nFor more information, see the manual page (i.e., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"systemd.service.5"}]},{"type":"text","value":").\nA summarized version can be found at "},{"type":"element","tagName":"a","properties":{"href":"/Service%20configuration"},"children":[{"type":"text","value":"Service configuration"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's an example of a user service resided as "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"$HOME/.config/systemd/user/drive-backup.service"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-ini"]},"children":[{"type":"text","value":"[Unit]\nDescription=Periodic safety backup for my external drive\nDocumentation=man:borg(1) https://www.borgbackup.org/ https://torsion.org/borgmatic/\n\n[Service]\nType=oneshot\nExecStart=%h/.nix-profile/bin/borgmatic --config %h/dotfiles/borgmatic/personal-drive.yaml --verbosity 2 create\nExecStart=%h/.nix-profile/bin/borgmatic --config %h/dotfiles/borgmatic/personal-drive.yaml --verbosity 2 prune\nExecStart=%h/.nix-profile/bin/borgmatic --config %h/dotfiles/borgmatic/personal-drive.yaml --verbosity 2 check\n\n[Install]\nWantedBy=default.target\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can then start the service with:\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"systemctl --user start drive-backup.service\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can also stop it with the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"stop"}]},{"type":"text","va