[ Unit ]
- Before=start service before specified service
- after=start service after specified service
- description=human readable title of systemd service
[ Service ]
ExecStart=command that needs to be executed when the service starts.
- ExecReload=how service is restarted.
- Type=indicates start-up type of process for given systemd service.(simple, exec, forking, oneshot, dbus, notify and idle)
- Restart=specifies if service should be restarted-depending on circumstances — or not.(no, on-success, on-failure, on-abnormal,on-watchdog, on-abort, always)
[ Install ]
installation of systemd service/unit file. This is used when you run systemctl start / systemctl disable
- WantedBy=similar to After and Before fields, but difference is that this is used to specify systemd-equivalent “runlevels”. The default target is when all system initialization is complete when the user is logging in.
- RequiredBy=similar to WantedBy but the difference is that this field specifies hard dependencies. Meaning if dependency fails this service will fail
Example script:
[ Unit ]
Description=example systemd service unit file
[ Service ]
ExecStart=/bin/bash /usr/sbin/example.sh
[ Install ]
WantedBy=multi-user.target