11

I really read many tutorials, but crontab doesn't start notify send.

What I've tried:

  1. etc/crontab

    added at the end:

    15 * * * * notify-send 'crontab' 'test'
    
  2. with crontab interface:

    crontab -e
    

    added at the end:

    15 * * * * notify-send 'crontab' 'test'
    
Jacob Vlijm
  • 85,475
Vitor Abella
  • 8,015
  • 16
  • 63
  • 115

2 Answers2

13

As suggested by @Lnux:

Create a .sh, for example test.sh:

#!/bin/sh
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)";

#Code:
DISPLAY=:0 notify-send "Test"

Then set up crontab:

crontab -e

And at the bottom, add:

* * * * * /home/myUser/test.sh

Obs.: you can place your .sh file in another location and don't forget to allow executing it.

Vitor Abella
  • 8,015
  • 16
  • 63
  • 115
6

Crontab is running in the background and without specified graphical output it will show nothing. So you should spicify, which output would you like to use. To achieve that, put export DISPLAY=:0 && before you command, e.g.

15 * * * * export DISPLAY=:0 && notify-send 'I am alive!'