![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Fresh Brewed Ubuntu
![]() |
First of all, please refer to this howto to learn more about crontab.
My motivation to find this out was because there are several radio shows I really like and I was always missing them. As such, I needed something to make amarok play the chosen radio station at specific times. Probably this could be achieved through a more elegant solution, but what is explained here works great. Also, I knew that by learning how to do this, I could use it for many other things. To accomplish this, you have to edit your crontab: Code:
crontab -e If you use a GUI tool, please adapt the instructions accordingly. I will explain this using as basis the default crontab editor. To run a GUI command on cron, you'll have to tell cron what display the program should use. For that you use: Code:
export DISPLAY=:0 So, you add to what is explained here: Code:
01 04 * * * /usr/bin/somedirectory/somecommand Code:
01 04 * * * export DISPLAY=:0 && /usr/bin/somedirectory/somecommand So, in my case, as I want amarok to play Antena2 (Portuguese classical radio station) at a specific time, I use: Code:
30 16 * * 7 export DISPLAY=:0 && amarok mms://rdp.oninet.pt/antena2 Code:
0 17 * * 7 export DISPLAY=:0 && amarok -s (Just a side note - to make amarok play mms urls, you have to set it to use xine engine) You can use this export trick to the limits of your imagination with every kind of application you want. Another example that occurs to me is when you neet to use an application for a certain period of time, from 3AM to 9AM, for exemple. Code:
0 3 * * * export DISPLAY=:0 && your_favorite_application Code:
0 9 * * * killall your_favorite_application Hope this helps some of you. If you have more ideas how to use this trick (or how to improve this HowTo), please share with us in the thread. Last edited by henriquemaia; January 21st, 2006 at 12:06 PM.. Reason: Needed some rephrasing on certain paragraphs and some information was added. |
|
|
|
|
|
#2 |
|
Fresh Brewed Ubuntu
![]() |
This howto was updated. Have a good time!
|
|
|
|
|
|
#3 |
|
A Carafe of Ubuntu
![]() |
Hi,henriquemaia
Nice work just like to ask is this somthing that may work with any prog???? Thank you
__________________
Registered Linux user #402077 |
|
|
|
|
|
#4 |
|
Fresh Brewed Ubuntu
![]() |
I suppose so. I have tested this with lots of apps and always managed to get them working. As long as you put on you crontab the correct command line caller* to the application you want, there should be no problem at all. It is a good practice to test the command line before introducing it in crontab. Under a terminal, run:
Code:
export DISPLAY=:0 && your_favorite_application Hope this helps you. *remember that the command line to call an application is not always the application name. For example, calculator's command caller is 'gcalctool' if you use Gnome or 'kcalc' if you use KDE. Just a reminder. |
|
|
|
|
|
#5 |
|
Just Give Me the Beans!
![]() Join Date: Jul 2005
Beans: 72
Xubuntu 9.04 Jaunty Jackalope
|
Re: HowTo make cron run GUI applications
Great how-to! Thanks a lot.
Also a good way to start an X-application from tty1.
__________________
www.neue-retro.de |
|
|
|
|
|
#6 | |
|
Fresh Brewed Ubuntu
![]() |
Re: HowTo make cron run GUI applications
Quote:
|
|
|
|
|
|
|
#7 |
|
A Carafe of Ubuntu
![]() Join Date: Feb 2006
Location: SW Wisconsin, USA
Beans: 100
Kubuntu 8.04 Hardy Heron
|
Re: HowTo make cron run GUI applications
Thanks for the tutorial. I did a neat thing with it, scheduling voice announcements of the time every half-hour. Don't ask me why, just thought it was neat. I like to hear them in the morning starting about sunrise, it can help if I have to get up at a certain time.
I went to the AT&T Labs Text-to-Speech demo page at: http://public.research.att.com/~ttsweb/tts/demo.php Picking my favorite voice (Lauren), I phonetically spelled out the time like so: Seven, thirty, ay em. This sounded better than typing: 7:30 am The "am" was spoken as am, the word, so AM and PM needed to be spelled phonetically. I put all the sound files in a folder under my home directory, and added in crontab a line for each of them according to the tutorial here, like so: Code:
30 07 * * * export DISPLAY=:0 && totem /home/ken/Documents/Sounds/Time/7-30am.wav
__________________
Kubuntu Hardy Heron Registered Linux user #422217 |
|
|
|
|
|
#8 | |
|
Fresh Brewed Ubuntu
![]() |
Re: HowTo make cron run GUI applications
Quote:
I also set up a reminder using images that pop up every 3 hours. The cool thing is that the possibilities are endless. Cron is a very useful tool. |
|
|
|
|
|
|
#9 | |
|
A Carafe of Ubuntu
![]() |
Re: HowTo make cron run GUI applications
This is not working for me! For example I put the following entry in crontab:
Code:
10 * * * * export DISPLAY=:0 && zenity --notification --text "This is a test." Quote:
|
|
|
|
|
|
|
#10 | |
|
Fresh Brewed Ubuntu
![]() |
Re: HowTo make cron run GUI applications
Quote:
I have tried the same command you shown and worked as expected. Even from the console (tty1). Last edited by henriquemaia; May 21st, 2006 at 03:04 AM.. |
|
|
|
|
| Bookmarks |
| Tags |
| crontab, gnome schedule |
| Thread Tools | |
| Display Modes | |
|
|