User Tools

Site Tools


ubuntu:services:scripts

Ubuntu - Services - Scripts

Using systemd

Example systemd script written in /lib/systemd/system/service_name.service:

systemctl cat service_name.service

returns:

[Unit]
Description=Job that runs the service_name daemon
Documentation=man:service_name(1)
[Service]
Type=forking
Environment=statedir=/var/cache/service_name
ExecStartPre=/usr/bin/mkdir -p ${statedir}
ExecStart=/usr/bin/service_name-daemon --arg1 "hello world" --statedir ${statedir}
[Install]
WantedBy=multi-user.target

Using Upstart

Example upstart script written in /etc/init/service_name.conf:

description "Job that runs the service_name daemon"
start on runlevel [2345]
stop on runlevel [016]
env statedir=/var/cache/service_name
pre-start exec mkdir -p $statedir
exec /usr/bin/service_name-daemon --arg1 "hello world" --statedir $statedir
ubuntu/services/scripts.txt · Last modified: 2020/07/15 10:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki