自定义系统脚本打印异常?

自定义系统脚本打印异常?

当我在后台运行这个脚本时,通常它每 600 秒打印一次,但我不知道为什么显示dmesg看起来像这样,就好像它堆叠在一起一样。我的系统是定制的,不是发行版本。文件系统是使用创建的busybox。我可以知道如何解决这个问题吗?

经过对比测试,发现是因为echo 1 > /proc/sys/vm/drop_caches &preventsleep 600没有生效。如果被阻止,sleep 600就会生效。为什么?

autoCacheFree.sh:

#!/bin/sh

drop_caches() {
    echo "Drop caches."
    sync
    echo 1 > /proc/sys/vm/drop_caches &
    return 0
}

while true; do
    sleep 600
    drop_caches
done

的信息dmesg

...
[ 1405.880208] autoCacheFree.s (19284): drop_caches: 1
[ 1405.895675] autoCacheFree.s (19286): drop_caches: 1
[ 1405.911123] autoCacheFree.s (19288): drop_caches: 1
[ 1405.926552] autoCacheFree.s (19290): drop_caches: 1
[ 1405.941609] autoCacheFree.s (19292): drop_caches: 1
[ 1405.957013] autoCacheFree.s (19294): drop_caches: 1
[ 1405.972305] autoCacheFree.s (19296): drop_caches: 1
[ 1405.987799] autoCacheFree.s (19298): drop_caches: 1
[ 1406.003028] autoCacheFree.s (19300): drop_caches: 1
[ 1406.018418] autoCacheFree.s (19302): drop_caches: 1
[ 1406.033637] autoCacheFree.s (19304): drop_caches: 1
[ 1406.049015] autoCacheFree.s (19306): drop_caches: 1
[ 1406.064032] autoCacheFree.s (19308): drop_caches: 1
[ 1406.079359] autoCacheFree.s (19310): drop_caches: 1
[ 1406.094496] autoCacheFree.s (19312): drop_caches: 1
[ 1406.110246] autoCacheFree.s (19314): drop_caches: 1
[ 1406.125805] autoCacheFree.s (19316): drop_caches: 1
[ 1406.141808] autoCacheFree.s (19318): drop_caches: 1
[ 1406.157118] autoCacheFree.s (19320): drop_caches: 1
[ 1406.172632] autoCacheFree.s (19322): drop_caches: 1
[ 1406.188490] autoCacheFree.s (19329): drop_caches: 1
[ 1406.204322] autoCacheFree.s (19331): drop_caches: 1
[ 1406.220455] autoCacheFree.s (19333): drop_caches: 1

相关内容