You are not logged in.

#1 2007-10-09 17:54:19

synthead
Member
Registered: 2006-05-09
Posts: 1,337

Restarting processes on a schedule

I have an mpd server running in our store so we can play music from the internet over our hi-fi.  It works great all day, however, when we come back in the morning, the audio is "skipping" like a perpetual underbuffer.  I believe that the reason lies with the station we're tuned into - I think they disconnect listeners sometime in the night. 

So what I need to do is shut down mpd and restart it at 5AM or something like that (unless you guys know of a better way to fix this).  How would I be able to do this?

Offline

#2 2007-10-09 18:09:46

elasticdog
Member
From: Washington, USA
Registered: 2005-05-02
Posts: 995
Website

Re: Restarting processes on a schedule

write a quick cron job to bring mpd down and back up

Offline

#3 2007-10-09 21:21:51

synthead
Member
Registered: 2006-05-09
Posts: 1,337

Re: Restarting processes on a schedule

How would one do that?

I see that there are easily editable cron configs in /etc, but how would I make it restart at 5AM specifically?

Offline

#4 2007-10-09 22:25:42

tam1138
Member
Registered: 2007-09-10
Posts: 238

Re: Restarting processes on a schedule

$ man crontab

Offline

#5 2007-10-09 23:04:15

synthead
Member
Registered: 2006-05-09
Posts: 1,337

Re: Restarting processes on a schedule

Crontab, nice.  How's this look?

#
# DO NOT EDIT THIS FILE MANUALLY!! USE crontab -e INSTEAD.
#

# <minute> <hour> <day> <month> <dow> <command>


01 * * * *  /usr/sbin/run-cron /etc/cron.hourly
02 00 * * * /usr/sbin/run-cron /etc/cron.daily
22 00 * * 0 /usr/sbin/run-cron /etc/cron.weekly
42 00 1 * * /usr/sbin/run-cron /etc/cron.monthly

00 5 * * * mpd --kill
01 5 * * * mpd

Offline

#6 2007-10-09 23:33:22

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,131

Re: Restarting processes on a schedule

synthead wrote:

Crontab, nice.  How's this look?

#
# DO NOT EDIT THIS FILE MANUALLY!! USE crontab -e INSTEAD.
#

# <minute> <hour> <day> <month> <dow> <command>


01 * * * *  /usr/sbin/run-cron /etc/cron.hourly
02 00 * * * /usr/sbin/run-cron /etc/cron.daily
22 00 * * 0 /usr/sbin/run-cron /etc/cron.weekly
42 00 1 * * /usr/sbin/run-cron /etc/cron.monthly

00 5 * * * mpd --kill
01 5 * * * mpd

You have to specify the path of mpd, change mpd to /usr/bin/mpd

Cheers Sigi


Haven't been here in a while. Still rocking Arch. smile

Offline

#7 2007-10-10 01:17:09

PeteMo
Member
From: H'Burg, VA
Registered: 2006-01-26
Posts: 191
Website

Re: Restarting processes on a schedule

you could also use /etc/rc.d/mpd restart

Offline

#8 2007-10-10 03:29:06

elasticdog
Member
From: Washington, USA
Registered: 2005-05-02
Posts: 995
Website

Re: Restarting processes on a schedule

PeteMo wrote:

you could also use /etc/rc.d/mpd restart

This is definitely the better option, so that would make it:

0 5 * * * /etc/rc.d/mpd restart

Offline

#9 2007-10-10 11:57:17

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: Restarting processes on a schedule

You can also set xinetd to run mpd from hour X to Y and shut it down afterwards. Very handy, and imho more sohpisticated than a cron job tongue.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#10 2007-10-10 22:28:16

synthead
Member
Registered: 2006-05-09
Posts: 1,337

Re: Restarting processes on a schedule

Got the cron job working, works great smile

How does xinetd work?

Offline

Board footer

Powered by FluxBB