How do i set the MemoryLimit using environment variable I have tried set MemoryLimit field by using the variable MY_LIMIT like this, The Service configuration:
[Unit]
Description=Blabla
[Service]
Environment="MY_LIMIT=1024"
MemoryLimit=$MY_LIMIT
ExecStart=script.sh
But this doesnt seems to work As we see that
sudo systemctl show myservice
Show that the MemoryLimit is a assigned with this value instead
MemoryLimit=18446744073709551615
systemd has an Environment directive which sets environment variables for executed processes. [source][1]
So your MY_LIMIT
won't get interpreted when set in MemoryLimit
.
Also MemoryLimit
is deprecated, use MemoryMax=
instead. [source][2]
So what you should set is: MemoryMax=1024M
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.