Amazon Linux – Where to Place Init Scripts

amazon-linuxamazon-web-servicesinit.d

In the Amazon Linux 2 release notes, Amazon advises that initscripts should no longer exist in /etc/init.d

Amazon Linux 2 uses the systemd 219 init system to bootstrap userspace and manage system processes. It is available as /sbin/init and replaces the System V-style init system that was available in the previous generation of Amazon Linux. As a result, initscripts should no longer exist in /etc/init.d. systemctl {start|stop|restart} SERVICE_NAME.service should be used in its place. Additionally, service SERVICE_NAME {start|stop|restart} is compatible with both Amazon Linux AMI and Amazon Linux 2.

We rely on an initscript to auto-start Supervisor when the instance boots. Is there a viable alternative under the systemd 219 init system?

Best Answer

The new way is to create systemd unit file for your application or startup script. It may seem like an overkill for simple startup scripts but it is the way that most current Linux distros adopted - Amazon Linux, Redhat, Ubuntu, Debian, they all use systemd so it pays to know how to do it properly.

Have a look here for example: Creating and modifying systemd unit files

Hope that helps :)