Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to get cron to provide a screen alert when it spots a particular situation. I know the script is executed each minute but it will not display on the screen.

script executed is:

DISPLAY=:0.0 /usr/bin/notify-send -t 1000 Test "This is a test"

Running Gnome from the Mandriva distribution.

Any ideas?

share|improve this question
    
Another way to do it unix.stackexchange.com/questions/28463/… –  akond Jul 20 '12 at 11:46
add comment

2 Answers 2

Is this your user's crontab, not root's crontab?

I'd suggest that, at least for debugging, you create a script as John T describes:

* * * * * /path/to/script.sh

Here's what the script might look like:

#!/bin/bash
{
    echo "trying to notify at $(date)"
    DISPLAY=:0.0 /usr/bin/notify-send -t 1000 Test "This is a test"
    echo "finished notify at $(date)"
} > /path/to/your-notify-debug.log 2>&1

Note that there's no ":" before DISPLAY, as you seem to have in your question. Be sure to make this script executable (chmod +x /path/to/script.sh) and let cron try to run it a few times. Then examine what was written to the logfile.

share|improve this answer
add comment

You need to be able to connect to the DBUS user session bus. This needs to be the session bus not the system bus. You can find that by doing a

set | grep DBUS_SESSION_BUS_ADDRESS

then in your script you need to have

export DBUS_SESSION_BUS_ADDRESS={whatever it is}

then do your notify-send

Since the session bus changes every time you login, you might want to add something to your login scripts to write the DBUS_SESSION_BUS_ADDRESS to a file so your script can read that in and export that.

share|improve this answer
1  
It may have already been saved to a file. Try using this at the start of your script: if [[ -z "$DBUS_SESSION_BUS_ADDRESS" ]]; then source "$HOME/.dbus/session-bus"/*-0 && export DBUS_SESSION_BUS_ADDRESS; fi –  dubiousjim Feb 28 '10 at 13:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.