SystemD

    Actions

    Enable docker service

    systemctl enable docker.service
    

    actions:

    • enable/disable to enable/disable the service
    • start/stop
    • mask/unmask service can't/can be started by other service even if disable
    • status

    Example

    Take a look in the directory /etc/systemd/system/multi-user.target.wants/

    One Shot

    Services declared as oneshot are expected to take some action and exit immediatelly

    [Unit]
    Description=Setup foo
    #After=network.target
    
    [Service]
    Type=oneshot
    ExecStart=/opt/foo/setup-foo.sh
    RemainAfterExit=true
    ExecStop=/opt/foo/teardown-foo.sh
    StandardOutput=journal
    
    [Install]
    WantedBy=multi-user.target
    

    Watch Logs

    journalctl -f -u docker.service
    

    List all enabled services

    systemctl list-unit-files | grep enabled
    

    List all services running

    systemctl | grep running