1

I'm trying to get the RAID status every time i boot into my system (Debian) and send the output as notification in the desktop. This works as expected from terminal: sudo mdadm --detail /dev/md0 | grep 'Working Devices :' | while read OUTPUT; do notify-send "$OUTPUT"; done

but it won't work if I run a crontab job pointing at the script :

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

The script is set to be executable and is ran from crontab root as:

@reboot /PATH/scripth.sh

this also won't work:

* * * * * /PATH/scripth.sh

and logs are not produced when:

* * * * * /PATH/scripth.sh > /PATH/crontab.log
cronoik
  • 15,434
  • 3
  • 40
  • 78
Xbert
  • 91
  • 1
  • 1
  • 5

1 Answers1

2

This work in my PC (change username):

sudo mdadm --detail /dev/md0 | grep 'Working Devices :' | while read OUTPUT; do su - RealUserName -c "DISPLAY=':0.0' notify-send \"$OUTPUT\""; done
Šerg
  • 793
  • 5
  • 18