0

I want to run a node application via systemd and have its output go to both stdout and a log file. The node app is in the folder named www/www.appname.com and I want to have the log file in www/log.appname.com. I have the following service servicename defined:

[Service]
ExecStart=/usr/bin/node server | tee -a ../log.appname.com/appname.service.log
KillMode=process
Restart=always
RestartSec=20
WorkingDirectory=/home/username/www/www.appname.com

[Install]
WantedBy=default.target

But when I run my service, e.g.

systemctl --user restart servicename

Then the folder www/log.appname.com remains blank, so maybe there's something wrong with the path name I'm using in the tee?

sigil
  • 103
  • 2

1 Answers1

2

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=sh -c 'dmesg | wc'

So try something like

ExecStart=sh -c '/usr/bin/node server | tee -a ../log.appname.com/appname.service.log'
asktyagi
  • 2,401
  • 1
  • 5
  • 19