Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve unit specifiers in /var/bot/error-$(date+%Y_%m_%d_%I_%M_%p).log: Invalid slot

I want to run NodeJS code as service, but whenever I add output to log files I get error with syntax.

● bot.service - simple NodeJS bot
     Loaded: bad-setting (Reason: Unit bot.service has a bad unit file setting.)
     Active: inactive (dead)

Dec 21 17:33:36 ubuntu systemd[1]: /etc/systemd/system/bot.service:9: Failed to resolve unit specifiers in /var/bot/error-$(date+%Y_%m_%d_%I_%M_%p).log: Invalid slot
Dec 21 17:33:36 ubuntu systemd[1]: bot.service: Unit configuration has fatal error, unit will not be started.

bot.service:

[Unit]
Description=simple NodeJS bot
After=network-online.target

[Service]
Restart=on-failure
SyslogIdentifier=bot
WorkingDirectory=/home/ubuntu/bot
ExecStart=/home/ubuntu/.nvm/versions/node/v16.6.2/bin/node /home/ubuntu/bot/out/index.js >> /var/bot/bot.log 2> /var/bot/"error-$(date+%Y_%m_%d_%I_%M_%p).log"

# limit CPU and RAM quota for our service
# Not necessary, but i am running other servers, so i need it
CPUAccounting=true
MemoryAccounting=true
SyslogIdentifier=bot

[Install]
WantedBy=multi-user.target
like image 303
Dave Player Avatar asked Jan 24 '26 08:01

Dave Player


1 Answers

The problem comes from the % sign. You need to escape it (%%) if you want the command to be accepted by systemd

like image 151
guest Avatar answered Jan 27 '26 00:01

guest



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!