I created the following service, amos.service, and it needs to run as amos (member of the amos group)

Description=AMOS Service

ExecStart=/usr/share/amos/amos_service.sh start
ExecStop=/usr/share/amos/amos_service.sh stop


all the permissions have been set on /usr/share/amos to amos:amos

the amos_service.sh is as follows:


CUDIR=$(dirname "$0")
cd /usr/share/amos

start() {
  exec /usr/share/amos/run_amos.sh >> /var/log/amos.log 2>&1  

stop() {
  exec pkill java 

case $1 in
  start|stop) "$1" ;;

cd "$CURDIR"

When I run the service initially without any modifications to the directories, meaning, belonging to root, and amos.service not having the User not Group parameter, everything runs great!

Once I change the directories permissions to amos:amos and add the amos.service User & Group, the serive won't work and I get the following : See attached image

Error after trying to run service

  • What is the difference, if any, between the success and failure cases in terms of the messages logged to /var/log/amos.log ?
    – sourcejedi
    May 4, 2017 at 18:59
  • Also, this configuration is odd in that /var/log is owned by root. I think you want to use a directory /var/log/amos/ which you create as owned by amos.
    – sourcejedi
    May 4, 2017 at 19:01
  • 1
    I will create as mentioned and will log back results
    – itprguy
    May 4, 2017 at 20:43
  • 2
    This exec pkill java is really bad! If you have any other service using Java, oh well... Nov 16, 2020 at 1:36

4 Answers 4


Use systemd:

To show the problem use journalctl -xe after you started the service.

You don't need a bash script, put this in your service file:


There is no need for ExecStop, systemd will stop all child processes. You can view the output with journalctl -u amos.service.


I think you want forking instead of simple. Simple assumes your process doesn't exit, so when it does, it calls the process dead.

You probably want to remove the amos_service.sh script and put it's functionality into the amos.service.

  • 1
    Will make changes as suggested...was reading about it and saw your comment. Will log back results.
    – itprguy
    May 4, 2017 at 20:44

First find your config you want to change using the following command:

systemctl list-unit-files

Then change the specific config using the following command:

sudo systemctl edit --full tomcat9.service

This will open the file in the default text editor set in the EDITOR environment variable.

Now add the specific user and group user service section.


Maybe authorize amos user to launch services thanks to the enable-linger option?

loginctl enable-linger amos

(cf. man loginctl, it seems to be mandatory)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .