You are not logged in.

#1 2007-09-12 03:07:35

YoungGods
Member
From: Europa
Registered: 2007-09-02
Posts: 23

[SOLVED] Cron job to start / stop Azureus - can not start azureus

Hi,

I changed to Arch from Ubuntu a couple of weeks ago and I'm trying to setup a cron job to run azureus everyday at 00:55 and stop it at 09:00.

Here's what my cron job looked like in Ubuntu:

55 00 * * *     DISPLAY=:0.0 /opt/azureus/azureus
00 09 * * *    DISPLAY=:0.0 && killall -SIGHUP java

I've tried it with Arch (replacing "opt/azureus/azureus" for "/usr/bin/azureus") but nothing happens.

To check if everything is ok with cron I tried the following:
- crontab -l  --> shows the crontab as expected
- 55 00 * * *     mkdir /home/###/test    --> the directory was created with no problems.
- running Azureus from the command line  --> no problems
- running it from the command line exactly as in cron "DISPLAY=:0.0 /opt/azureus/azureus" --> azureus started OK
- replacing azureus for thunderbird, firefox, konqueror, etc in the cron file - none of the apps was started.

So, I can not get cron to launch apps but it can create folders, remove files, etc.

Help would be appreciated.

Thanks,

Last edited by YoungGods (2007-09-15 04:13:31)

Offline

#2 2007-09-12 23:45:45

George_K
Member
From: Russie, Saint-Pétersbourg
Registered: 2006-09-27
Posts: 75

Re: [SOLVED] Cron job to start / stop Azureus - can not start azureus

Cron user can`t start applications on your user`s display. To allow cron run graphical applications, you can run "xhost +local:" under your main user (which opened display).
But I`m sure there are better ways of doing the thing you want. Also you can look at xmove (http://wiki.archlinux.org/index.php/All … plications).

Offline

#3 2007-09-12 23:54:58

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [SOLVED] Cron job to start / stop Azureus - can not start azureus

Why don't you use something like transmission instead of azureus?  Are there any azureus-only functions that you find indispensable?  Transmission package comes with a non-graphical? (not sure, I've never tried it) daemon that can be run on startup and I imagine that it would be much easier to set up cron to run/stop the transmission daemon rather than azureus...   Just a thought.

Offline

#4 2007-09-14 21:24:09

YoungGods
Member
From: Europa
Registered: 2007-09-02
Posts: 23

Re: [SOLVED] Cron job to start / stop Azureus - can not start azureus

First of all, thank you for your replies.
I tried "xhost +local:" with no success.
I could use something else, like transmission, but I'm sure there's a way to launch graphical applications with cron.
If it can be done in Ubuntu with just 2 lines, I'm sure it can be done in Arch.

Anyone else using Cron to launch graphical applications?

Offline

#5 2007-09-14 21:48:38

tam1138
Member
Registered: 2007-09-10
Posts: 238

Re: [SOLVED] Cron job to start / stop Azureus - can not start azureus

This worked for me with no modifications to xhost:

* * * * * DISPLAY=:0.0 xclock

so chances are the problem is with azureus and/or java rather than cron and/or X.  Try changing the cron entry to redirect output to a file and see if it says anything.  eg:

* * * * * DISPLAY=:0.0 /usr/bin/azureus &>/tmp/azureus.out

Last edited by tam1138 (2007-09-14 21:50:42)

Offline

#6 2007-09-15 00:19:05

YoungGods
Member
From: Europa
Registered: 2007-09-02
Posts: 23

Re: [SOLVED] Cron job to start / stop Azureus - can not start azureus

Hi tam1138,

Tried "* * * * * DISPLAY=:0.0 xclock" and the clock started with no problems.

Here's the output of "* * * * * DISPLAY=:0.0 /usr/bin/azureus &>/tmp/azureus.out "

/usr/bin/azureus: line 3: java: command not found

Just to test, I installed Ktorrent. Can not start it from cron.
Output of DISPLAY=0.0 /opt/kde/bin/ktorrent &>/tmp/ktorrent.out

kdeinit: Can't connect to the X Server.
kdeinit: Might not terminate at end of session.
kded: cannot connect to X server 0.0
DCOP aborting call from 'anonymous-29832' to 'kded'
kded: ERROR: Communication problem with kded, it probably crashed.
Qt: Warning: ktorrent: cannot connect to X server 0.0
DCOP aborting call from 'anonymous-29819' to 'ktorrent'
ERROR: Communication problem with ktorrent, it probably crashed.

Offline

#7 2007-09-15 01:10:53

tam1138
Member
Registered: 2007-09-10
Posts: 238

Re: [SOLVED] Cron job to start / stop Azureus - can not start azureus

I'm not a KDE person so I can't speak to the latter.  The former, however, is easy: java is not in the path provided by cron.  You have two options to deal with this.

a) Modify the path just for that command:

* * * * * PATH="$PATH:/opt/java/jre/bin" /usr/bin/azureus

b) Write a script that sets the path, and execute that:

* * * * * ~/bin/run-azureus.sh

and in ~/bin/run-azureus.sh:

#!/bin/sh
export PATH=$PATH:/opt/java/jre/bin
/usr/bin/azureus

There are pros and cons to both, I suppose, but I would probably use the latter.

Offline

#8 2007-09-15 04:11:56

YoungGods
Member
From: Europa
Registered: 2007-09-02
Posts: 23

Re: [SOLVED] Cron job to start / stop Azureus - can not start azureus

tam1138,

option B worked great.

Thank you for your help .

Offline

Board footer

Powered by FluxBB