PDA

View Full Version : How do I start a task through terminal using cron?


unni
11-03-2007, 09:53 PM
Hi friends,
I want to schedule apt-mirror so that it would start at 2 am. But the problem is that there is no feedback of what's going on after the job starts. I am sure that its running and is doing what it is supposed to do. If I start it from konsole, apt-mirror would say "this much data is to be downloaded, this much number of files to be downloaded" etc. How do I set cron such that it would launch the apt-mirror task through konsole?

eddie
12-03-2007, 10:20 AM
You can execute your command in konsole by prefixing it with "konsole -e". For example if I want to run a mpg321 instance in a new konsole window then I would give the following command
konsole -e mpg321 /home/edward/xyz.mp3 &
When executed from a command window, this will create a new konsole window and start mpg321 in it, which will play xyz.mp3 file.

Before you put this code in your crontab file do remember to check that your xhost allows connections from root because that is what you'll be doing. You can also wait for mediator (or PM him) to come in and see your problem. He might have a solution using a bash script.

unni
12-03-2007, 11:18 AM
Thanks eddie:) . I used the following command:
DISPLAY=unix:0 /usr/bin/konsole -e apt-mirror
This was what I wanted.
Before you put this code in your crontab file do remember to check that your xhost allows connections from root because that is what you'll be doing.
What did you mean by this? I didn't run the above as root, only as a normal user with sudo privilege. I am using Ubuntu.

eddie
13-03-2007, 01:03 AM
In some distros executing GUI applications with "super user" privileges is not allowed. That is what I was referring to.

Vivek788
17-03-2007, 05:20 AM
can u give me a brief info on using cron effectively?

eddie
18-03-2007, 07:41 PM
^ Here is one for you
http://gentoo-wiki.com/Cron