5

I want to write a script to enable my program on boot automatically. This can be done using SysV Init, Upstart or systemd. However, I am not able to figure out which init system my Raspbian uses.

Another doubt I have is that, suppose the default init system is upstart, then will a script written and enabled with systemd work? To rephrase, do we need to write init script in the default init system to make it work?

5

Raspian is basically Debian.

Debian until and including Wheezy/7 used SysV, since Jessie/8 systemd.

Upstart is not relevant anymore, since even RHEL and Ubuntu (the Upstart developers) have moved to systemd.

systemd is very different from sysv. However, there is a compatibility layer in systemd that will transparently create units for properly annotated sysv init scripts on the fly. If you plan to distribute your init script to other raspian users, a well-tested sysv init script will also work in systemd. While systemd is pretty complex, creating services is actually surprisingly simple.

As for the init system on your machine, stat /sbin/init should give you a good indication on Debian. For general initsystem detection, this Unix&Linux question has excellent answers. u

  • The question link to on U&LSE is marked as a duplicate of this one! Also - Debian (and thus Raspbian) do provide a working choice for init systems on both Wheezy and Jessie versions - those indications are the defaults but the opposite (SysV init vs. systemd) can be selected - all my machines (PCs & RPis) use SysV init even though some are using Jessie...! 8-) {For the record do not try to install upstart into an init using Jessie system directly - that breaks very badly... 8-( } – SlySven Feb 22 '16 at 19:07
  • sudo stat /sbin/init File: ‘/sbin/init’ Size: 284844 Blocks: 560 IO Block: 4096 regular file Device: b307h/45831d Inode: 669590 Links: 1 Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2016-02-17 22:15:59.000000000 +0300 Modify: 2014-12-09 15:36:55.000000000 +0300 Change: 2016-02-17 22:16:07.991854912 +0300 Birth: - This is the output. I cannot figure out the init system from this. – Adi Feb 27 '16 at 12:15
  • I was able to find out using answers here.unix.stackexchange.com/questions/18209/… – Adi Feb 27 '16 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.