LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 01:22 AM   #1
reynacho_au
Member
 
Registered: Nov 2004
Distribution: Mandrake 10.1
Posts: 43

Rep: Reputation: 15
Crontab


I'm trying to use crontab as an alarm. I have a playlist called "Playlist.m3u" in my home directory. I added my user to /etc/cron.allow and used crontab -e to set up the job that I want. Here is what my job is:

30 7 * * 1-5 xmms /home/<user>/Desktop/Playlist.m3u

The problem is that it just doesn't run. I've tried specifying the exact path to xmms (/usr/bin/xmms) and putting the parameters in parenthesis. I also created a shell script with one line to execute /usr/bin/xmms /home/<user>/Desktop/Playlist.m3u and it will not run that way either.

I changed entry and added > /home/<user>/cron.log 2>&1 to the end of the entry and did not get any output whatsoever.

I have verified that crond is running and even restarted it. I have added root to the cron.allow file and added root entries and they don't run either. I have no clue what else to try. I looked in /var/logs/cron and there was nothing in the errors file or warnings file and the info file just has all the different lines that have been attempted to be executed and they all looked correct.

The only thing I found is that I made a different entry for testing which was:

* * * * * /usr/bin/xmms > /home/<user>/cron.log 2>&1

and I got the output:

** CRITICAL **: Unable to open display.

if I run /usr/bin/xmms from a console it opens the program without a problem.

Someone please tell me what else I can try.

Thank you in advance.
 
Old 12-28-2004, 01:38 AM   #2
reynacho_au
Member
 
Registered: Nov 2004
Distribution: Mandrake 10.1
Posts: 43

Original Poster
Rep: Reputation: 15
I also tried setting a job to echo something and that didn't work either
 
Old 12-28-2004, 01:45 AM   #3
zoiks
LQ Newbie
 
Registered: Dec 2004
Distribution: SuSE 9.1 Pro on Intel 2.4GHz (Dell Optiplex GX260)
Posts: 20

Rep: Reputation: 0
I think the problem is that there is no x server display defined when cron launches the command. X-based applications usually inherit the display server from the shell or program they were launched from. The cron daemon does not generally have any connection to an X server.

I think what you need is a command-line based player.

I googled and found this list: http://www.linuxlinks.com/Software/M...le/index.shtml Hopefully one of these will open a playlist. You should probably check if your distro already supports a command-line player.
 
Old 12-28-2004, 01:50 AM   #4
reynacho_au
Member
 
Registered: Nov 2004
Distribution: Mandrake 10.1
Posts: 43

Original Poster
Rep: Reputation: 15
I'm using Mandrake 10.1 and on previous versions of Mandrake I know I've been able to start xmms.

I just added a line * * * * * /usr/bin/mpg123 <music file> and it did not work. I tried the same from the console and it worked fine.
 
Old 12-28-2004, 02:21 AM   #5
zoiks
LQ Newbie
 
Registered: Dec 2004
Distribution: SuSE 9.1 Pro on Intel 2.4GHz (Dell Optiplex GX260)
Posts: 20

Rep: Reputation: 0
Quote:
Originally posted by reynacho_au
I'm using Mandrake 10.1 and on previous versions of Mandrake I know I've been able to start xmms.

I just added a line * * * * * /usr/bin/mpg123 <music file> and it did not work. I tried the same from the console and it worked fine.
You should be able to start xmms no problem from a shell that you launch from within your graphical desktop. But if you log into root, does it still launch? My guess is no.

When I try xmms from my regular shell it works no problemo; when I log in as root, even with '-', I get the same error you did regadring the display. Cron runs as root, and it's not run from a graphical shell, so it won't launch without some sort of tweaking that I don't know how to do.

As an example, I just installed mp3blaster. I can run it both as regular user and as root. When I type

mp3blaster Sonique\ -\ It\ Feels\ So\Good.mp3

it starts playing immediately.

I haven't tried mpg123. What error messages do you get when you try it?
 
Old 12-28-2004, 02:25 AM   #6
reynacho_au
Member
 
Registered: Nov 2004
Distribution: Mandrake 10.1
Posts: 43

Original Poster
Rep: Reputation: 15
no error messages from mpg123. Try setting up a cron job on your system to use your mp3player and see if it still works. I logged in as root and xmms worked fine still.

Since you mentioned that cron runs as root I added localhost to the xhosts list by running "xhost + localhost". I've gotten the same error as you sometimes about not being able to open the display and that usually fixed it. cron still did not work.
 
Old 12-28-2004, 03:09 AM   #7
zoiks
LQ Newbie
 
Registered: Dec 2004
Distribution: SuSE 9.1 Pro on Intel 2.4GHz (Dell Optiplex GX260)
Posts: 20

Rep: Reputation: 0
Quote:
Originally posted by reynacho_au
no error messages from mpg123. Try setting up a cron job on your system to use your mp3player and see if it still works. I logged in as root and xmms worked fine still.

Since you mentioned that cron runs as root I added localhost to the xhosts list by running "xhost + localhost". I've gotten the same error as you sometimes about not being able to open the display and that usually fixed it. cron still did not work.
I just tried a few things and got it to work. This is what I did: (I'm running SuSE, but this should work for you too):

1) I created a script called playmp3 and put it in /etc. The contents of the script are:

#!/bin/sh
export TERM=xterm
/usr/bin/mp3blaster "<home>/Music/Sonique - It Feels So Good.mp3"

2) I chmod'ed it to make it executable:

chmod u+x /etc/playmp3

3) I added /etc/playmp3 to the crontab with 59 * * * *.

4) When 12:59 PST arrived, I was treated to nice music from my loudspeakers. Granted, I had no explicit control of the music - I'd have to kill the process - but at least it worked.

The "export TERM=xterm" did the trick. I haven't tried it for use with an X app, perhaps you should give that a try.

Uh, I better go undo the crontab entry or I'll be hearing this music in my dreams.
 
  


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
crontab x2??? killahsmurf Slackware 2 05-24-2005 10:53 PM
Crontab wormraper Debian 4 05-15-2005 01:01 AM
How to use crontab ? Dakkar Linux - Newbie 2 01-22-2004 10:49 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM
HELP!! crontab karleong Linux - General 9 07-12-2003 10:54 AM

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

All times are GMT -5. The time now is 12:36 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