LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cron alert message (https://www.linuxquestions.org/questions/linux-general-1/cron-alert-message-914621/)

r_jr 11-20-2011 11:05 PM

cron alert message
 
I am not sure where to put this so I am posting the question here.

I am attempting to create a cron script to check the connection to a server using fping. Now this works, but I need to somehow alert the user on the gnome desktop. I tried using gxmessage, but the messagebox never pops up though it does work in a terminal. I was wondering how do I use gxmessage box or some other way to create an alert message as part of a cron script.

corp769 11-20-2011 11:21 PM

Have you tried using zenity? I run Fedora, and have successfully used zenity within cron a few times. Have a look here - http://linux.byexamples.com/archives...og-examples-2/

Cheers,

Josh

D1ver 11-21-2011 02:46 AM

I'm not sure if this is related but I needed to add
Code:

export DISPLAY=:0.0
To get a script working as a cron job that used feh to change the background. Maybe gxmessage doesn't know which screen you're asking it to display on?

corp769 11-21-2011 04:44 PM

Quote:

Originally Posted by D1ver (Post 4529468)
I'm not sure if this is related but I needed to add
Code:

export DISPLAY=:0.0
To get a script working as a cron job that used feh to change the background. Maybe gxmessage doesn't know which screen you're asking it to display on?

After thinking about it, that might be the issue. If running from a standard terminal, of course it wouldn't work, but exporting the DISPLAY environment would definitely tell it to use the first X server that is allocated on the OP's system.

r_jr 11-22-2011 02:55 AM

Quote:

Originally Posted by corp769 (Post 4530107)
After thinking about it, that might be the issue. If running from a standard terminal, of course it wouldn't work, but exporting the DISPLAY environment would definitely tell it to use the first X server that is allocated on the OP's system.

Yes, that was it though you are wrong in that it did work from a standard terminal. It only did not work as a cron script. But after adding the export DISPlay:=0 && to my command, it now works. Thanks though.

:)

corp769 11-22-2011 09:02 AM

Quote:

Originally Posted by r_jr (Post 4530505)
Yes, that was it though you are wrong in that it did work from a standard terminal. It only did not work as a cron script. But after adding the export DISPlay:=0 && to my command, it now works. Thanks though.

:)

I was talking about an actual terminal, and not a virtual terminal, like you would run gnome-terminal with X.


All times are GMT -5. The time now is 11:35 PM.