Bash

如何使用 systemd 在啟動時設置 cpumask?

  • February 15, 2020

我有以下服務:

[Unit]
Description=foo

[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/opt/script/bar.sh

[Install]
WantedBy=multi-user.target

並且bar.sh

#!/bin/bash
echo 1 > /sys/bus/workqueue/devices/writeback/cpumask
cat /sys/bus/workqueue/devices/writeback/cpumask > /tmp/writeback

然後我重新啟動後,cat /tmp/writeback看起來不錯: 000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001

/sys/bus/workqueue/devices/writeback/cpumask被覆蓋回預設值:

ffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff

想法?

也許使用 ExecStart 而不是 ExecStop?

引用自:https://serverfault.com/questions/1003192