我有一个 systemd 文件来启动一个 jar 文件。但我想以 身份执行 jar 文件*.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
我尝试过这个,但是没有用。
答案1
从man 5 systemd.service
(“命令行”部分):
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