Auto startup apps in /etc/rc.local not loading

I have the following in my /etc/rc.local
mpd
mpc
exit 0

but for some reason mpc and mpc are not loading on a reboot. If I putty in, I can start them manually.
What am I missing?

1 Like

Are those commands enough to daemonise them?
And remember that there is no console.

You should try starting them detached with &

mpd &
mpc &
exit 0

Or even start detached subshells for them:

( mpd )&
( mpc )&
exit 0

Tried both methods and neither worked

Also tried changing the permissions of /etc/rc.local to executable and that didn't help either

Try this and see what is in the log file after reboot.

mpc 2>&1 > /tmp/mpc.log

I wonder if PATH is not properly set for rc.local

mpc 2>&1 > /tmp/mpc.log
says
mpd error: connection refused
[1]+ Done(1)

whatever that means

I have never used those apps, so pure guess:

mpc (client?) complains that it can't connect to mpd (server?). So, mpd fails first and that leads to mpc failure

Do the same logging thing for mpd and see what error that gives.

It is also possible that there apps gets launched a bit too early so that e.g. firewall is not yet properly up. You might try adding a "sleep 10" as the first line of the script.

And maybe a sleep in between...

Went into they system log and and see this
user.notice : mpd error: Connection refused

but it runs fine when I manually launch it in putty

I'll try a long delay and see if that helps

Sleep 30 before MPD didn't help at all.

Does it rely on the internet connection to be up? If you are in PPPoE then it can take a while to create a wan connection.

Start them from command line and run this command to see what connections that app opens:

netstat -nap | egrep "mpd|mpc"

Ok, I think I found the problem. I had to modify the file locations in mpd.conf
instead of "~/music" and "~/.mpd/playlists etc.

Had to be
"/root/.mpd/playlists" etc

Not sure if this was caused by the Extroot but it's running on statup now. Not sure the items in in the startup are actually running but mpd is fired up which is what I need.

Thanks all for the advice

Sort of curious - Why can't you use /etc/init.d/mpd? There should be a link to it in /etc/rc.d
Why do you launch mpc as a deamon?

I have experienced similar problem
The main cause is the rc.local startup too early
While mpd mpc be called, some environment is not prepared, such as interface bring up still not finished
You could found error log from syslog or kernel log.(Sure could found, but not sure which one)

My solution is add sleep 10 at begining of rc.local