testing操作系统: RHEL7
所需的操作系统 :RHEL&Derivatives&AIX
我有一个用户创build如下:
sudo groupadd madt sudo useradd -r -g madt -s /bin/false madt
该用户正在systemd服务中使用,如下所示:
[Unit] Description=MicroStrategy Mobile Access Distribution Tool After=syslog.target [Service] User=madt ExecStart=/usr/bin/java -jar /opt/pandera/mobile-registration/mobile-access-distribution-tool-1.0.0.jar --spring.config.location=/opt/pandera/mobile-registration/ SuccessExitStatus=143 [Install] WantedBy=multi-user.target
Java应用程序要求存在一个环境variables。 我已经在/etc/environment设置了这个variables,并确认它可以用于root和所有其他的交互式用户。
我怎样才能让madt用户识别我的环境variables?
您可以在systemd单元中使用EnvironmentFile行。
例如
EnvironmentFile=/etc/environment
然后Systemd将读取您的文件并将variables从文件注入到程序的环境中。
如果只需要为该系统单元设置单个环境variables,请使用
Environment=VERBOSITY_LEVEL=1