5
5
I am trying to set a date inside the unit file for logging
my unit file look like this:
[Unit]
Description=Jetty service
After=multiuser.target
[Service]
Environment=MAIN_CLASS="com.candorgrc.nphase.MainJetty"
Type=simple
User=jetty
Group=jetty
WorkingDirectory=/home/jetty/dist
PermissionsStartOnly=true
ExecStartPre=/bin/systemctl set-environment date=$(/bin/date +%%Y-%%m-%%d-%%H-%%M)
ExecStart=/usr/bin/java -Xms512m -Xmx1024m -Djava.util.logging.config.file=/home/jetty/logging.properties -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/u01/jetty/hdumps/hdump_${date} -verbose:gc -Dcom.sun.management.jmxremote.port=12321 -Dcom.sun.management.jmxremote.authen
PIDFile=/var/run/jetty.pid
ExecReload=/bin/kill -HUP $MAINPID
#Restart=on-failure
ExecStop=/bin/kill -9 $MAINPID
Setting the date does not seam to be working. The error I get is the following:
Nov 26 16:47:50 vps203756 systemctl[14275]: Failed to set environment: Invalid environment assignments
Nov 26 16:47:50 vps203756 systemd[1]: jetty.service: Control process exited, code=exited status=1
Nov 26 16:47:50 vps203756 systemd[1]: jetty.service: Failed with result 'exit-code'.
Nov 26 16:47:50 vps203756 systemd[1]: Failed to start Jetty service.
Any idea how to configure it for it to work?
1
See also https://unix.stackexchange.com/questions/323914/dynamic-variables-in-systemd-service-unit-files
– rogerdpack – 2019-05-23T16:06:29.923