This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Start Kmail from cron

Tags: None
(comma "," separated)
xendistar
Registered Member
Posts
3
Karma
0
OS

Start Kmail from cron

Sun Jan 03, 2010 10:10 pm
I am trying to start kmail via cron but I can't get kmail to start, here is what
cron looks like

mit@Titan:~$ crontab -l
# Stop kmail
0 5 * * * killall -9 kmail
# start kmail
15 5 * * * /usr/bin/kmail --check
# This file was written by KCron. Copyright (c) 1999, Gary Meyer
# Although KCron supports most crontab formats, use care when editing.
# Note: Lines beginning with "#\" indicates a disabled task.

On the start Kmail line I have tried the following wording

kmail
"kmail"
'kmail'
/usr/bin/kmail
kmail -caption "%c" %i %m (this is the command from the start menu kmail icon)

Basicly kmail is killed at 5:00am everyday and I want kmail to start again at
5:15am everyday, but kmail won't start.

I am using KDE 3.5.10 and Kmail 1.9.9 on Mepis 8 (Debian Lenny)

The reason for this is that my PC runs 24\7 and I collect from several e-mail
accounts, but sometime one of them goes awol and I won't get any mail through.
But when I close down kmail or reboot and then restart kmail there is a deluge
of mail from that particular box

Any suggestion??

Tim
User avatar
google01103
Manager
Posts
6668
Karma
25

Re: Start Kmail from cron

Sun Jan 03, 2010 10:35 pm
iirc the problem is cron executes in a non windowed environment (not in your kde session) so you can't run kde/gnome apps from cron but you can run them from kalarm (assuming there's an existing kde session for it to execute the program in). Just create a command alarm at 5:15am and set recurrence to daily.
xendistar
Registered Member
Posts
3
Karma
0
OS

Re: Start Kmail from cron

Mon Jan 04, 2010 7:31 am
Thanks Google, I installed and setup kalarm and kmail was up and running ok this morning.

I assume the fact that I can type kmail into konsole and it will start kmail is the fact that konsole is running within a KDE enviroment and as you suggest cron is working outside of the kde enviroment?


Tim
User avatar
JanGerrit
Moderator
Posts
647
Karma
3
OS

Re: Start Kmail from cron  Topic is solved

Mon Jan 04, 2010 8:22 am
The first graphical session you start is normally available with Ctrl+Alt+F7. You can switch to terminals with Ctrl+Alt+F1,F2,F3 up to F6. Ctrl+Alt+F8 would be a new graphical session, if you start one.
If you execute this on a terminal you can access through Ctrl+Alt+F2 or one of the other F-keys the application will start on your graphical session:
Code: Select all
export DISPLAY=:0.0
kmail

In Konsole the environment variable DISPLAY is set. You can see this by executing
Code: Select all
echo $DISPLAY
in a Konsole window.
If you use the following as cron command for KMail it should start in your graphical session:
Code: Select all
bash -c "DISPLAY=:0.0 /usr/bin/kmail --check"


Image
xendistar
Registered Member
Posts
3
Karma
0
OS

Re: Start Kmail from cron

Mon Jan 04, 2010 7:06 pm
Thanks Jan, that worked perfectly

Tim
User avatar
JanGerrit
Moderator
Posts
647
Karma
3
OS

Re: Start Kmail from cron

Mon Jan 04, 2010 8:18 pm
No problem ;)

Could you mark the topic as solved please (press the green hook at the post which solved your problem)? Thanks.


Image


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]