[root@localhost ~]# cat /usr/bin/cgroup_swappiness_set.sh #!/bin/sh CGROUP_V1_MEMORY_DIR=$(mount | grep "^cgroup .*memory" | cut -d ' ' -f 3) if [ -z $CGROUP_V1_MEMORY_DIR ]; then exit -22 # EINVAL fi GLOBAL_SWAPPINESS=$(cat /proc/sys/vm/swappiness) for cg in $(find $CGROUP_V1_MEMORY_DIR -name memory.swappiness); do echo $GLOBAL_SWAPPINESS > $cg done [root@localhost ~]# chmod +x /usr/bin/cgroup_swappiness_set.sh [root@localhost ~]# cat /usr/lib/systemd/system/swappiness_fix.service [Unit] Description=Set all existing -v1 memory cgroups to global vm.swappiness After=systemd-sysctl.service [Service] Type=oneshot ExecStart=/usr/bin/cgroup_swappiness_set.sh [Install] WantedBy=multi-user.target [root@localhost ~]# systemctl enable swappiness_fix.service