LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-28-2004, 08:44 PM   #1
reynacho_au
Member
 
Registered: Nov 2004
Distribution: Mandrake 10.1
Posts: 43

Rep: Reputation: 15
Crontab loading X apps


I'm trying to set up cron to be an alarm on my box and to start playing a song or playlist using xmms. Nothing seems to work. I am on Mandrake 10.1 and all security is set to standard. After much trial and error and using this forum I got it to work by setting a script called 'alarm' with the following syntax:

#!/bin/sh
export TERM=xterm
mpg123 "<song_title>"

and my crontab looks like:

* * * * * <home>/alarm

First of all, yes the script is executable and the <home> and <song_title> are the actual directory and song title.

That worked fine but it will load mpg123 in xterm and I can't see it so I have to manually search out the PID using 'ps aux | grep mpg' and kill it manually.

I know I've done this on previous versions of Mandrake where my crontab was a very simple line such as: * * * * * /usr/bin/xmms "<song_title>"

Anyone know any ways of making cron start an X app?

By the way, as a test, I ran a cron job to do: * * * * * /usr/bin/xmms and redirected the output to a log file and got the following message: "** CRITICAL **: Unable to open display".

So, I thought to add localhost to the xhosts access control using "xhost + localhost". It was successfully added but still nothing.

Any help?
 
Old 12-28-2004, 08:55 PM   #2
reynacho_au
Member
 
Registered: Nov 2004
Distribution: Mandrake 10.1
Posts: 43

Original Poster
Rep: Reputation: 15
One thing to note is that "at" will not work either and I tried creating a cron job through webmin and it would not even let me access it. I clicked the link and there was nothing there, it didn't even change pages.
 
Old 12-28-2004, 09:03 PM   #3
Moy Easwaran
Member
 
Registered: Dec 2004
Distribution: Slackware, OpenBSD
Posts: 44

Rep: Reputation: 19
I've never done this but I'd guess that you at least need to export DISPLAY=whatever (just like you exported TERM).
 
Old 12-28-2004, 09:06 PM   #4
reynacho_au
Member
 
Registered: Nov 2004
Distribution: Mandrake 10.1
Posts: 43

Original Poster
Rep: Reputation: 15
good point, however I'm not sure if DISPLAY is a global variable that I can use and I don't know what to set it to if it is.

That's interesting, I wonder if cron runs independently of anything already running. If that's so, how do I tell cron to use the current display for a particular job.

By the way, I'm running KDE 3.2
 
Old 12-28-2004, 09:43 PM   #5
Moy Easwaran
Member
 
Registered: Dec 2004
Distribution: Slackware, OpenBSD
Posts: 44

Rep: Reputation: 19
Quote:
good point, however I'm not sure if DISPLAY is a global variable that I can use and I don't know what to set it to if it is.
When you export it that also sets it in bash, which is /bin/sh on Mandrake as on Mandrake's ancestor Red Hat. If you were using the original Bourne shell you'd have to split that up: TERM=xterm; export TERM

I just tested adding the following line to my crontab and it works:
Code:
* * * * * export DISPLAY=:0.0; /usr/bin/xmms /home/.../file.ogg
Quote:
That's interesting, I wonder if cron runs independently of anything already running. If that's so, how do I tell cron to use the current display for a particular job.
Not sure what exactly you mean by this, but yes, the cron daemon runs independently of everything else (except init, of course). It kicks off your cron job, which then talks to the X server, which also runs independently of everything else (except init and possibly the font server if you're running that separately).

HTH.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
loading apps on startup pukington Linux - Newbie 4 01-19-2006 12:35 AM
Frustration on loading new apps galliar SUSE / openSUSE 5 01-30-2005 02:39 AM
slow loading apps when eth0 is up cgraf Linux - Networking 3 01-20-2004 03:17 PM
Already installed apps not loading after rpm installer for other apps toastermaker Linux - Newbie 11 11-17-2003 11:25 AM
VERY slow apps. loading peteheff Linux - General 7 01-17-2003 11:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration