Skip to content

Instantly share code, notes, and snippets.

@petrkohut
Last active March 16, 2017 09:16
Show Gist options
  • Save petrkohut/863a059062b1a0dbd466 to your computer and use it in GitHub Desktop.
Save petrkohut/863a059062b1a0dbd466 to your computer and use it in GitHub Desktop.
How to setup Systemd (tested on Debian:jessie)

How to setup Systemd

Create our first autostarted daemon service

sudo vim /etc/systemd/system/ping.service

Edit this file like this:

[Service]
ExecStart=/bin/ping google.com
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=ping-google
#WorkingDirectory=

[Install]
WantedBy=multi-user.target

Make daemon to be autostarted on boot of system

sudo systemctl enable ping.service

or we can do it manually by creating a symlink:

sudo ln -s /etc/systemd/system/ping.service /etc/systemd/system/multi-user.target.wants/ping.service

Restart systemd and test our daemon

Restart:

sudo systemctl daemon-reload

Check status of our daemon:

sudo systemctl status ping.service

See the output of our service:

sudo journalctl -u ping-google

Systemd as a cron replacement

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment