且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从systemd bash内联脚本创建filename _ $(日期%Y-%m-%d)

更新时间:2022-04-16 03:52:41

您需要转义 $ 符号,

如此处所述:

  • https://github.com/systemd/systemd/issues/2146
  • https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines

要传递文字美元符号,请使用 $$

To pass a literal dollar sign, use "$$"



ExecStart=/bin/bash -c 'echo $$(date +%%Y-%%m-%%d) >> /home/username/test_output_$$(date +%%Y-%%m-%%d).log'