如何向 /etc/rc.local 添加多个命令?

如何向 /etc/rc.local 添加多个命令?

我想向/etc/rc.local文件中添加两个省电命令。

禁用蓝牙:

 rfkill block bluetooth

这会降低屏幕亮度:

echo 3024 > /sys/class/backlight/intel_backlight/brightness

单独添加/etc/rc.local它们可以工作,但不能像这样一起添加:

#/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

echo 3024 > /sys/class/backlight/intel_backlight/brightness

rfkill block bluetooth

exit 0

如何添加这两个命令才能使它们在启动时正确执行?

更新

原来是时间问题。我通过延迟执行第一个命令来解决这个问题:

(sleep 5; echo 3021 > /sys/class/backlight/intel_backlight/brightness)&

答案1

原来是时间问题。楼主建议通过延迟第一个命令的执行来解决这个问题,如下所示:

(sleep 5; echo 3021 > /sys/class/backlight/intel_backlight/brightness)&

哈克尔曾建议过在评论中

相关内容