7

I have a systemd file to start a jar file. But I want to execute jar file as *.jar. Is there a way to do this?

[Unit]
Description=Test Background

[Service]
ExecStart=/usr/bin/java -jar /var/www/test.com/*.jar
Type=simple
WorkingDirectory=/var/www/test.com

[Install]
WantedBy=multi-user.target

I tried this but not working.

muru
  • 207,228
Janith
  • 399

1 Answers1

7

From man 5 systemd.service (section "Command Lines"):

This syntax is inspired by shell syntax, but only the meta-characters and expansions
described in the following paragraphs are understood, and the expansion of variables is
different. Specifically, redirection using "<", "<<", ">", and ">>", pipes using "|",
running programs in the background using "&", and other elements of shell syntax are not
supported.

And:

Note that shell command lines are not directly supported. If shell command lines are to be
used, they need to be passed explicitly to a shell implementation of some kind. Example:

   ExecStart=/bin/sh -c 'dmesg | tac'

Wildcards are not mentioned as being supported, so you'll have to wrap that command in /bin/sh -c or /bin/bash -c like in the above example.

muru
  • 207,228