I am trying to create a cron job that sends a notification via notify-send.

I am currently trying this:

*/2 * * * * DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus /usr/bin/notify-send "test"

which is working if I just run it from a terminal.

I've also tried setting


I have a similar crontab that runs a shell script with the same variables that is printing to a log file, so I know that the crontab is working. But still, no notifications are showing up.

Does anyone have any idea of what might be wrong?

I am running with Ubuntu 17.10 with i3 on top

  • Set XDG_SESSION_COOKIE as well. And check your DBUS_SESSION_BUS_ADDRESS for a valid value. Aug 14, 2018 at 10:50
  • my DBUS_SESSION_BUS_ADDRESS seems to be valid... never seen the XDG_SESSION_COOKIE before. Do you have any suggestion as to what to set it to?
    – munHunger
    Aug 14, 2018 at 10:53
  • my DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-idumFnhFQ6,guid=484c45028754af8abc0cbc995b72642b'. Are you sure you have more simple value? Aug 14, 2018 at 11:13
  • Well, I am not entirely sure. but running printenv my DBUS_SESSION_BUS_ADDRESS looks like that
    – munHunger
    Aug 14, 2018 at 12:22

1 Answer 1


I run i3 on Ubuntu 18.04. This is how I solve it:

* * * * * XDG_RUNTIME_DIR=/run/user/$(id -u) notify-send Hey "this is dog!"

  • 3
    I tried dozens of suggestions to fix this issue and this is the only one that worked for me. Thanks.
    – dain
    Feb 20, 2019 at 21:46
  • 1
    Thanks - this helped me out as well. I opted to export this variable in the shell script I'm running, to keep my crontab clean.
    – Try431
    Aug 18, 2019 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.