Originally published at: https://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html
Thank you for your awesome article!!!
I would inform you that under Linux Mint 18.3 (based upon Ubuntu 16.04), the notify send does not work under CRON, not event setting the DISPLAY variable.
Is there another workaround?
Thank you so much,
Antonio
Try something as following in cron:
DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus /usr/bin/notify-send "This is a test."
Where, 1000 is your user id and it can be located with id command:
id -u
For sudo try (run it as foo user with id 2000):
/usr/bin/sudo -u foo DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/2000/bus /usr/bin/notify-send 'Hello world!' 'I am running and doing something for you.'
journalctl -f --user
will follow the user’s log on a Fedora 27.