This script works fine in user's crontab, but I need run from ROOT crontab, but not work:
#!/bin/sh
# cron.sh
# Notifies the user of date and time
source /home/user/.bashrc
pid=$(pgrep -u user openbox | head -n 1)
dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$pid/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//' )
export DBUS_SESSION_BUS_ADDRESS=$dbus
export HOME=/home/user
export DISPLAY=:0
/usr/bin/notify-send 'title' "$(/bin/date)"
The script was found here: crontab script
The script is placed on /home/user/cron.sh with all permissions(777). My root crontab is:
* * * * * /home/user/cron.sh
If I use this script in normal user crontab it works and show the popup text, but not from root crontab.
Syslog (/var/log/syslog ) not show errors when crontab trigger.