---
title: Run AM as a service
description: AM can run as a service on a standard systemd-based Linux distribution. Once you have configured AM as a service, you can stop and start AM using systemd.
component: pingam
version: 8.1
page_id: pingam:installation:run-am-service
canonical_url: https://docs.pingidentity.com/pingam/8.1/installation/run-am-service.html
keywords: ["Install"]
page_aliases: ["install-guide:run-am-service.adoc"]
section_ids:
  configure-am-service: Configure AM as a service
  manage-am-service: Use systemctl commands to manage the AM service
---

# Run AM as a service

AM can run as a service on a standard `systemd`-based Linux distribution. Once you have configured AM as a service, you can stop and start AM using `systemd`.

These instructions assume you have deployed AM on Apache Tomcat.

|   |                                                                                                                                                                                                                                                                                                                                                                            |
| - | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | A service file (called `tomcat`) is created if you install Tomcat using a package manager such as `yum`. You can use this service file instead of creating your own.You can [enable](#enable) this service to run on startup and [manage the Tomcat service](#manage-am-service) using `systemctl` commands. Replace `am.service` in these example commands with `tomcat`. |

## Configure AM as a service

1. Create a service file using your preferred text editor:

   ```bash
   $ sudo vim /etc/systemd/system/am.service
   ```

2. Add the following content to this file, update all the values as needed, and save:

   ```ini
   [Unit]
   Description=AM (Apache Tomcat)
   After=network.target

   [Service]
   Type=forking

   Environment=JAVA_HOME=/path/to/jdk
   Environment=CATALINA_PID=/path/to/tomcat/temp/tomcat.pid
   Environment=CATALINA_HOME=/path/to/tomcat
   Environment=CATALINA_BASE=/path/to/tomcat
   Environment='CATALINA_OPTS=-Xmx2048m -server -XX:+UseParallelGC'
   Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

   ExecStart=/path/to/tomcat/bin/startup.sh
   ExecStop=/path/to/tomcat/bin/shutdown.sh

   User=tomcat_user
   Group=tomcat_user

   [Install]
   WantedBy=multi-user.target
   ```

3. Reload the daemon:

   ```bash
   $ sudo systemctl daemon-reload
   ```

4. []()Make the new service launch on startup:

   ```bash
   $ sudo systemctl enable am.service
   ```

5. Check the service is enabled:

   ```bash
   $ systemctl is-enabled am.service
   ```

   This command returns `enabled` or `disabled` as appropriate.

## Use systemctl commands to manage the AM service

Once you've configured AM as a service and checked it's enabled, use `systemctl` commands to manage the AM service:

* Start the service:

  ```bash
  $ sudo systemctl start am.service
  ```

* Stop the service:

  ```bash
  $ sudo systemctl stop am.service
  ```

* Restart the service:

  ```bash
  $ sudo systemctl restart am.service
  ```

* Check the service status:

  ```bash
  $ sudo systemctl status am.service
  ```

  This command returns the service state (whether the service has started or stopped as expected) and the first few entries of the AM log file.
