PDA

View Full Version : Re: Daemonized MP3 player (linux)



Jake Hawkes
2003-11-10, 14:46
--- Michael Herger <mherger (AT) jo-sac (DOT) ch> wrote:
> > Just run it with & and then type exit.
> > It should stay running - I do it all the time.
>
> First "exit" gives me the message "There are stopped jobs", but I don't
> exit. Second "exit" does its job, but halts the program as well.

so, write a script like this, call it "runmpg123":
--------------------------------------------------------
#!/bin/sh

while 1
do
mpg123 http://localhost:9000/stream.mp3
echo "Restarting mpg123" >> runmpg123.log
done
--------------------------------------------------------

mark it executable:
chmod +x runmpg123

then run it:
nohup runmpg123

and logout. The nohup will do the same as disown. Use disown if you have started a process and
want to insulate it against a nohup from the shell. Use nohup if you know you want to insulate
the process from nohups when you start it.

If you want to get real fancy, you could replace the line:
echo "Restarting mpg123" >> runmpg123.log
with:
echo "display mpg123 stopped 120" | nc -w1 localhost 9001

which would display the fact that mpg123 had been restarted on the slimp display.
**Note: you will need netcat for the 'nc' command to work.



=====
Jacob Hawkes, B. Eng (CSE)
jakehawkes2001 (AT) yahoo (DOT) com
http://www.infinitylimited.net/

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

Ted Rathkopf
2003-11-10, 15:22
Aaarr, Jake Hawkes <jakehawkes2001 (AT) yahoo (DOT) com>
What ye be sayin'?

> --- Michael Herger <mherger (AT) jo-sac (DOT) ch> wrote:
>> > Just run it with & and then type exit.
>> > It should stay running - I do it all the time.
>>
>> First "exit" gives me the message "There are stopped jobs", but I don't
>> exit. Second "exit" does its job, but halts the program as well.
>
> so, write a script like this, call it "runmpg123":
> --------------------------------------------------------
> #!/bin/sh
>
> while 1
> do
> mpg123 http://localhost:9000/stream.mp3
> echo "Restarting mpg123" >> runmpg123.log
> done

That log isn't going to tell you very much. better would be:

echo "`date '+%Y%m%d %H:%M:%S'` restarting mpg123" >> runmpg123.log

--
Ted Rathkopf