Существует ли способ использовать подстановочные знаки, перенаправление или другой синтаксис оболочки с systemd единицами?

У меня есть systemd файл для запуска файла банки. Но я хочу выполнить файл банки как *.jar. Существует ли способ сделать это?

[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

Я попробовал это, но не работу.

2
задан 16 December 2018 в 15:14

1 ответ

От man 5 systemd.service (раздел "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.

И:

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'

Подстановочные знаки не упоминаются как поддерживаемый, таким образом, необходимо будет перенести ту команду в /bin/sh -c или /bin/bash -c как в вышеупомянутом примере.

3
ответ дан 2 December 2019 в 02:41

Другие вопросы по тегам:

Похожие вопросы: