init.d
- put hello.sh as
/usr/lib/hello/hello.sh
and$ chmod a+x hello
- put init.d/hello as
/etc/init.d/hello
$ runlevel
to see current runlevel$ chkconfig --add {servicename}
$ sudo chkconfig --level {current runlevel} hello on
- rc script has chkconfig magic comment and it defines runlevel, so actually this step is not necessary
$ chkconfig
$ service hello status
servicectl
- put hello.sh as
/usr/lib/hello/hello.sh
and$ chmod a+x hello
- put systemd/hello.service as
/etc/systemd/system/hello.service
$ systemctl get-default
to see current target$ cat /etc/systemd/system/hello.service
and see value ofWantedBy
which is same as what we see in step 3$ systemctl list-unit-files --type=service | grep hello
to see the service is recognized by systemctl or not$ systemctl enable hello
to enable it (= create symlink)$ systemctl status hello