我尝试使用日期输出作为 systemd 单元中日志文件名的一部分。这里的例子:
[Unit]
Description=TCS minetest server unit
[Service]
Type=simple
ExecStart=/home/tcs/minetest/bin/minetestserver --worldname world --logfile /home/tcs/logs/debug_$$(date +%%Y_%%m_%%d).txt
ExecReload=/bin/kill -HUP $MAINPID
User=tcs
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
但我得到日志文件:
ls /home/tcs/logs/
'debug_$(date'
Run Code Online (Sandbox Code Playgroud)
如何使用当前日期作为日志文件名?