I am trying to setup a daily reminder using cron and I thought I could use kdialog and cron to do just that… Apparently, I am doing something wrong.
1- I have created a new task to execute: kdialog --title=“Test” --msgbox=“This is a test!”
2- I set the time a a single time event to test that the scheduled task works (e.g. a couple of minute after the the actual time)
3- I’ve clicked OK to confirm the task and Apply on the main cron window.
On 2010-07-29 13:36, pomchip wrote:
>
> Hi,
>
> I am trying to setup a daily reminder using cron and I thought I could
> use kdialog and cron to do just that… Apparently, I am doing something
> wrong.
Yes: that you can not run a graphical application from cron, that is designed to run without
terminal (not text, even less graphical).
You will have to dig out documentation out there on how to determine if there is a graphical display
running, if your user is logged in there, and then how to display it. I do not know how exactly to
do that, so I can’t tell.
Or perhaps there is method to send a message for kde to display. Is it dbus? :-?
–
Cheers / Saludos,
Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Elessar))
Cron runs a process until it is done Any child process will end when the parent process ends. So the cron process starts the GUI process then ends thus the GUI process is killed also and never gets a chance to run. try putting a & after GUI the command this should start it as a new process and not be a child.
You may need to make it a script that cron runs, which first sets and exports the DISPLAY environmental variable, then runs kdialog. For example, just go out to a virtual terminal and try running kdialog --title=“Test” --msgbox=“This is a test!” and you will get an error “can not connect to X server” - this is what also happens when your cron job runs. However running: export DISPLAY=:0; kdialog --title=“Test” --msgbox=“This is a test!” will work okay. So, you could make this into a script . . . called say myMessage.sh containing:
#!/bin/bash
export DISPLAY=:0
kdialog --title=“Test” --msgbox=“This is a test!”
Then have cron point to where you have saved this and it should run fine.