AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1100779
Accepted
Janith
Janith
Asked: 2018-12-14 20:28:28 +0800 CST2018-12-14 20:28:28 +0800 CST 2018-12-14 20:28:28 +0800 CST

有没有办法在 systemd 单元中使用通配符、重定向或其他 shell 语法?

  • 772

我有一个 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

我试过这个但没有工作。

services systemd wildcards
  • 1 1 个回答
  • 1598 Views

1 个回答

  • Voted
  1. Best Answer
    muru
    2018-12-14T20:43:00+08:002018-12-14T20:43:00+08:00

    从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类似的示例中。

    • 5

相关问题

  • Ubuntu 服务器的 Chkconfig 替代品?

  • “服务”和“/etc/init.d/”有什么区别?

  • 延长笔记本电脑和笔记本电脑电池寿命的技巧

  • 命令列出启动时启动的服务?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve