1

每次我启动到我的系统(Debian)时,我都会尝试获取 RAID 状态并将输出作为通知发送到桌面。这可以从终端按预期工作: sudo mdadm --detail /dev/md0 | grep 'Working Devices :' | while read OUTPUT; do notify-send "$OUTPUT"; done

但如果我运行指向脚本的 crontab 作业,它将不起作用:

mdadm --detail /dev/md0 | grep 'Working Devices :' | while read OUTPUT; do notify-send "$OUTPUT"; done

该脚本设置为可执行,并从 crontab 根目录运行:

@reboot /PATH/scripth.sh

这也行不通:

* * * * * /PATH/scripth.sh

并且在以下情况下不会生成日志:

* * * * * /PATH/scripth.sh > /PATH/crontab.log
4

1 回答 1

2

这在我的电脑上工作(更改用户名):

sudo mdadm --detail /dev/md0 | grep 'Working Devices :' | while read OUTPUT; do su - RealUserName -c "DISPLAY=':0.0' notify-send \"$OUTPUT\""; done
于 2019-10-09T12:21:59.217 回答