Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
crontab & alarm clock & wake on lan - not working?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
derverstand
Guru
Guru


Joined: 15 Dec 2005
Posts: 511
Location: /dev/null

PostPosted: Wed Jan 14, 2009 8:55 am    Post subject: crontab & alarm clock & wake on lan - not working? Reply with quote

Hi,

Is there a maximum idle or runtime a command (which is invoked by crontab) can have?

My problem is the following:

I want to wake up by using mplayer & cron.

This is my crontab
Code:

30 5 * * wed /opt/mediacenter/bin/alarm


Where alarm is a script like
Code:

wol AA::BB::CC
sleep $((60*5))
export MPD_HOST=myhost.abc.de
FILE="MUSIC.mp3"
mpc clear
mpc add $FILE
mpc volume 1
mpc play
for i in $(seq 1 70); do
   mpc volume $i
   sleep 1
done
sleep 320
mpc stop


The alarm script itself works nicely. When I use atd to start my alarm the script works like supposed. But the crontab entry somehow doesn't work. In the logfile I checked, that the script actually starts. But maybe the sleep is too long and therefore cron kills the job?

I'd be grateful for any hint :)

/G
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7267
Location: almost Mile High in the USA

PostPosted: Wed Jan 14, 2009 4:14 pm    Post subject: Reply with quote

An easy way to debug is to just use a real alarm clock and get up then, and check what's happening :)

I don't recall there ever being an issue with long sleeps in cron jobs...

One thing I've sometimes noticed is that for any audio playing program, if you're not logged in, pam/udev may change the permissions of the audio system so the cron job no longer has access and all your audio fails.

I've had to simply disable audio (specifically, v4l) device ownership change and let them be, so cron will work (using cron to make a poorman's pvr).
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
derverstand
Guru
Guru


Joined: 15 Dec 2005
Posts: 511
Location: /dev/null

PostPosted: Wed Jan 14, 2009 4:55 pm    Post subject: Reply with quote

:D

The permissions shouldn't matter: All the processes are living as root...

/G
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7267
Location: almost Mile High in the USA

PostPosted: Thu Jan 15, 2009 1:39 am    Post subject: Reply with quote

ahh... now I think I see what your setup is a remote dedicated music player that you're trying to wake-on-lan?
Suppose the wake-on-lan fails, then all subsequent commands fail? Something like WOL commands I tend to run a few times in case the magic packet somehow gets ignored due to the network switch chomping a packet...

There should be debug output if something fails... is anything being mailed to root (which is the user you're using)? Cron should send stdout through mail, at least my hour-long pvr record through cron works just fine.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
baeksu
l33t
l33t


Joined: 26 Sep 2004
Posts: 609
Location: Seoul, Korea

PostPosted: Thu Jan 15, 2009 2:01 am    Post subject: Reply with quote

You could add lines like 'echo `date` "step n" >> ~/alarm-script.log' to your script to see if cron is indeed running the whole script, or even add echo for each command (including the variable) to see what the script is supposedly doing.

That's an quick and dirty way to debug bash scripts, imho.
_________________
Gnome:
1. A legendary being.
2. A never ending quest to make unix friendly to people who don't want unix and excruciating for those that do.
Back to top
View user's profile Send private message
timeBandit
Bodhisattva
Bodhisattva


Joined: 31 Dec 2004
Posts: 2674
Location: here, there or in transit

PostPosted: Thu Jan 15, 2009 2:42 am    Post subject: Reply with quote

cron doesn't like scripts that lack a shebang line; IIRC the result is more or less as you decribe. Add:
Code:
#!/bin/bash
...as the first line of your script and see if it works.
_________________
Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum