You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, March 21st 2004, 3:41am

How I can launc KDE apps with KCron?

Hi guys

I need to launch some apps of KDE 3.2 usint KCron, or similar, but I think cron is only for console programs.

Some people says cron have not access to X server.

Ideas? :?

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Sunday, March 21st 2004, 9:31am

cron can launch X11 programs, but they have to know which XServer to connect to.

This can be done by setting the environments DISPLAY variable.

The user runnging the XServer might have to allow connects by other users, using tools like xhost.

You can check by switching to a virutal terminal, e.g CTRL+ALT+F1, login as the user the cron job will run for, set DISPLAY (usually ":0") and start the program.

Cheers,
_
Qt/KDE Developer
Debian User

3

Sunday, March 21st 2004, 5:01pm

I tried this, but...

#!/bin/bash
set DISPLAY=:0
export DISPLAY
my_app

This is the script what cron executes, but not run. I can lauch this manually, and then run. I thin the error is in DISPLAY, but I am searching in the configuration files of X11 and I only see this:

:0 local /usr/X11R6/bin/X

With the set command, I see:

set DISPLAY=:0.0

I tried with this, but not run. ¿Maybe because the root launch X and my user launch my_app?

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

4

Sunday, March 21st 2004, 5:04pm

Have you tried running the script as the same user that cron uses to execute the job? I.e. the user who's crontab you edited.

Cheers,
_
Qt/KDE Developer
Debian User

5

Sunday, March 21st 2004, 5:17pm

I think, yes.

In the terminal of X (inside KDE), the script launch my app without problems.

In cron, of my user again. the script not launch.

I see a strange opcion: when the time of the job arribes, the option called "Execute Now" in secondary menu of mouse is turn on.

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

6

Tuesday, March 23rd 2004, 7:46pm

No, not in a console open from KDE.
I meant one of Linux virtual terminals, like you can get when pressing CTRL+ALT+F1 when in X11.

login as the user the cron job will run as and try to run your script.

Cheers,
_
Qt/KDE Developer
Debian User

7

Wednesday, March 24th 2004, 5:21am

Yes, in the Linux virtual terminal I can run manually the script, this works.

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

8

Wednesday, March 24th 2004, 9:46am

Strange.
Seems the cronjob has still a different environment than a normal user.

Can you redirect your app's output streams to files, so you can look at their output after the cronjob ran.

Something like

[code:1]
#!/bin/bash
DISPLAY=:0
export DISPLAY
my_app > /tmp/myapp.stdout 2> /tmp/myapp.stderr
[/code:1]

Cheers,
_
Qt/KDE Developer
Debian User

9

Thursday, March 25th 2004, 4:46am

FIXED

Curious. In the stderr says 'not found', and exists in the path :?:

I was solved this writing the exact path. Example:

The script is in /home/Altair/Launch_App

Launch_App have:

------------------
#!/bin/bash
export DISPLAY=:0.0
/usr/local/bin/my_app
------------------

I am testing different positions, at this moment, runs okay :)

Thanks for all :D

10

Thursday, March 25th 2004, 9:13am

You can always add & export the PATH in your script too! :wink:
or add a variable.

#!/bin/bash
export DISPLAY=:0.0
TOOL=/home/Altair
$TOOL/my_app

or

#!/bin/bash
export DISPLAY=:0.0
PATH=$PATH:/home/Altair; export PATH
my_app

Have fun!
The Best Games are for Download @ GCCLINUX