Results 1 to 6 of 6

Thread: Trying to use kdialog in cron

  1. #1

    Default Trying to use kdialog in cron

    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.
    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.

    Nothing happened at the supposedly given time.

    I am running opensuse 11.2 with KDE.

    Any help would be greatly appreciated.

    Sebastien

  2. #2
    Carlos E. R. NNTP User

    Default Re: Trying to use kdialog in cron

    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))

  3. #3
    Join Date
    Jun 2008
    Location
    Bandung, Indonesia
    Posts
    64

    Default Re: Trying to use kdialog in cron

    hi.
    haven't tried it myself, but please take a look at this:
    link
    Linux user: #448598
    openSUSE Indonesia: http://opensuse.or.id/

  4. #4
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    15,585

    Default Re: Trying to use kdialog in cron

    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.

  5. #5

    Default Re: Trying to use kdialog in cron

    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.

    Cheers,
    Lews Therin

  6. #6

    Thumbs up Re: Trying to use kdialog in cron

    Thanks Lews your help,

    Your solution worked just fine!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •