How do I start a task through terminal using cron?

Status
Not open for further replies.

unni

In the zone
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

El mooooo
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
Code:
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.
 
OP
unni

unni

In the zone
Thanks eddie:) . I used the following command:
Code:
DISPLAY=unix:0 /usr/bin/konsole -e apt-mirror
This was what I wanted.
eddie said:
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

El mooooo
In some distros executing GUI applications with "super user" privileges is not allowed. That is what I was referring to.
 
Status
Not open for further replies.
Top Bottom