Amazon Linux v 2.0 does support systemd and comes installed by default:

cat /etc/os-release
NAME="Amazon Linux"
VERSION="2.0 (2017.12)"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2.0"
PRETTY_NAME="Amazon Linux 2.0 (2017.12) LTS Release Candidate"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2.0"
HOME_URL="https://amazonlinux.com/"

rpm -qa | grep -i systemd
systemd-libs-219-42.amzn2.4.x86_64
systemd-219-42.amzn2.4.x86_64
systemd-sysv-219-42.amzn2.4.x86_64`
Answer from supaflysnooka on serverfault.com
🌐
GitHub
github.com › robertdebock › docker-amazonlinux-systemd
GitHub - robertdebock/docker-amazonlinux-systemd: Container to test Ansible roles in, including capabilities to use systemd facilities · GitHub
This Dockerfile can build containers capable to use systemd. This repository has multiple branches that relate to amazonlinux versions.
Author   robertdebock
Discussions

When using Amazon AMI for Linux, should I use systemd or sysv init files for creating a service for my Java based app?
Amazon Linux AMI use sysv. The new Amazon Linux 2 will use systemd, but I don't think it's GA yet. More on reddit.com
🌐 r/aws
3
1
May 14, 2018
Command not found: systemctl on Amazon Linux 2018.03 - Stack Overflow
As far as I know I would recommend ... of Linux taht supports systemd if operating systemd is mandatory for your requirement. Cause I don't think it is something that you can install as a package on your OS 2018-08-24T17:59:10.863Z+00:00 ... @Jason I confirm that the Amazon Linux AMI ... More on stackoverflow.com
🌐 stackoverflow.com
Adding a systemd service file
A Hibernating Agent for Linux on Amazon EC2. Contribute to aws/ec2-hibernate-linux-agent development by creating an account on GitHub. More on github.com
🌐 github.com
1
July 16, 2018
How do I configure my Amazon Linux service to auto-restart if it fails? - Unix & Linux Stack Exchange
If your version of Amazon Linux is >=2.0, it has systemd by default. In this case, you should simply be able to use the same unit file you have been using on CentOS, with the restart directives. If you are you are running Amazon Linux AMI, you will need to either use a separate supervisor to monitor your process (as poige mentioned), or utilize /etc/inittab. For example... More on unix.stackexchange.com
🌐 unix.stackexchange.com
🌐
AWS
docs.aws.amazon.com › amazon linux › user guide › running applications on al2023 › limiting process resource usage in al2023 using systemd
Limiting process resource usage in AL2023 using systemd - Amazon Linux 2023
Using systemd is a powerful and ... Amazon Linux in the third party EPEL repository. For comprehensive information, see the upstream systemd documentation for systemd.resource-control · , or the man page for systemd.resource-control on an AL2023 instance. The examples below will ...
🌐
GitHub
github.com › compwright › amazonlinux-2023-systemd
GitHub - compwright/amazonlinux-2023-systemd
Running systemd inside docker has historically been very difficult to nearly impossible. However, this has become substantially easier in recent years due to advances in Docker, the Linux kernel, systemd, and distros that use them—such as Amazon Linux 2023 (loosely based on Fedora).
Author   compwright
🌐
AWS
docs.aws.amazon.com › amazon linux › user guide › what is amazon linux 2023? › networking service
Networking service - Amazon Linux 2023
May 22, 2026 - Learn about the capabilities of the systemd-networkd project that's available in Amazon Linux distributions.
Find elsewhere
🌐
Amazon Web Services
aws.amazon.com › compute › amazon linux 2 › faqs
Amazon Linux 2 FAQs
2 weeks ago - A Linux kernel tuned for performance on Amazon EC2. A set of core packages including systemd, GCC 7.3, Glibc 2.26, Binutils 2.29.1 that receive Long Term Support (LTS) from AWS.
🌐
GitHub
github.com › compwright › amazonlinux-2023-systemd › blob › master › README.md
amazonlinux-2023-systemd/README.md at master · compwright/amazonlinux-2023-systemd
Running systemd inside docker has historically been very difficult to nearly impossible. However, this has become substantially easier in recent years due to advances in Docker, the Linux kernel, systemd, and distros that use them—such as Amazon Linux 2023 (loosely based on Fedora).
Author   compwright
🌐
GitHub
github.com › aws › ec2-hibernate-linux-agent › issues › 2
Adding a systemd service file · Issue #2 · aws/ec2- ...
July 16, 2018 - I am currently packaging ec2-hibernate-linux-agent for openSUSE and I have added a systemd service file as follows: [Unit] Description=Hibernating Agent for Linux on Amazon EC2 After=network.target Requires=network.target [Service] Type=simple ExecStart=/usr/bin/hibagent --config /etc/hibagent-config.cfg [Install] WantedBy=multi-user.target
Author   aws
🌐
Medium
medium.com › @jbornhoft › upgrading-systemd-on-amazon-linux-2-70c7532b6580
Upgrading systemd on Amazon Linux 2 | by Jason Bornhoft | Medium
January 18, 2023 - I recently ran into a situation, ... using Amazon Linux 2 and I needed to upgrade the version of systemd to the latest, or something close to it at least. In this case, the yum command is not helpful and the task needs to performed manually. The first step is to get the lay of the land and determine what your starting point is. In this example, I’m using ...
🌐
cloudonaut
cloudonaut.io › migrating-to-amazon-linux-2
Migrating to Amazon Linux 2 | cloudonaut
June 27, 2018 - Amazon Linux 2 uses systemd as the init system. systemd executes elements of its startup sequence in parallel, which is faster than the traditional serial approach from SysVinit.
Top answer
1 of 2
4

systemd is not supported in Services. The only correct is sysvinit:

services:
  sysvinit:
    my_worker:
      enabled: "true"
      ensureRunning: "true"

But I don't think it will even work, as this is for Amazon Linux 1, not for Amazon Linux 2.

In Amazon Linux 2 you shouldn't be even using much of .ebextensions. AWS docs specifically write:

On Amazon Linux 2 platforms, instead of providing files and commands in .ebextensions configuration files, we highly recommend that you use Buildfile. Procfile, and platform hooks whenever possible to configure and run custom code on your environment instances during instance provisioning.

Thus, you should consider using Procfile which does basically what you want to achieve:

Use a Procfile for long-running application processes that shouldn't exit. Elastic Beanstalk expects processes run from the Procfile to run continuously. Elastic Beanstalk monitors these processes and restarts any process that terminates. For short-running processes, use a Buildfile.

Alternative

Since you already have created a unit file /etc/systemd/system/my_worker.service for systemd, you can enable and start it yourself.

For this container_commands in .ebextensions can be used. For example:

container_commands:
   10_enable_worker:
     command: systemctl enable worker.service
   20_start_worker:
     command: systemctl start worker.service
2 of 2
1

It's not officially documented, but you can use a systemd service in Amazon Linux 2.

A block like the following should work:

services: 
    systemd:
        __SERVICE_NAME__:
            enabled: true
            ensureRunning: true

Support for a "systemd" service is provided by internal package /usr/lib/python3.7/site-packages/cfnbootstrap/construction.py which lists recognized service types: sysvinit, windows, and systemd

class CloudFormationCarpenter(object):
    _serviceTools = {"sysvinit": SysVInitTool, "windows": WindowsServiceTool, "systemd": SystemDTool}

Note that a systemd service must support chkconfig and in particular your launch script at /etc/init.d/__SERVICE_NAME__ must include a "chkconfig" and "description" line similar to:

# chkconfig: 2345 70 60
# description: Continuously logs Nginx status.

If you don't support chkconfig correctly then chkconfig --list __SERVICE_NAME__ will print an error, and attempting to deploy to Elastic Beanstalk will log a more detailed error in /var/log/cfn-init.log when it tries to start the service.

🌐
AWS
aws.amazon.com › blogs › aws › amazon-linux-2-modern-stable-and-enterprise-friendly
Amazon Linux 2 – Modern, Stable, and Enterprise-Friendly | Amazon Web Services
November 3, 2022 - SystemdAmazon Linux 2 includes the systemd init system, designed to provide better boot performance and increased control over individual services and groups of interdependent services. For example, you can indicate that Service B must be started only after Service A is fully started, ...
🌐
Tenable
tenable.com › plugins › nessus › 173905
Amazon Linux 2 : systemd (ALAS-2023-2004)<!-- --> | Tenable®
Run 'yum update systemd' to update your system. https://alas.aws.amazon.com/AL2/ALAS-2023-2004.html · https://alas.aws.amazon.com/cve/html/CVE-2023-26604.html ... Supported Sensors: Frictionless Assessment AWS, Frictionless Assessment Agent, Nessus Agent, Agentless Assessment, Continuous Assessment, Nessus ... CPE: cpe:/o:amazon:linux:2, p-cpe:/a:amazon:linux:systemd, p-cpe:/a:amazon:linux:systemd-sysv, p-cpe:/a:amazon:linux:systemd-debuginfo, p-cpe:/a:amazon:linux:systemd-devel, p-cpe:/a:amazon:linux:systemd-python, p-cpe:/a:amazon:linux:systemd-libs, p-cpe:/a:amazon:linux:systemd-networkd, p-cpe:/a:amazon:linux:libgudev1-devel, p-cpe:/a:amazon:linux:libgudev1, p-cpe:/a:amazon:linux:systemd-resolved, p-cpe:/a:amazon:linux:systemd-journal-gateway