Page 1 of 1

Auto updating music library

PostPosted: 12 Feb 2018, 11:44
by Nick.Moshulu
Hi,
I'm using a Pi 3 model B, using a NAS to store the music, but for some reason I can't get the library to update it's self without manually doing it. I know what command to use via SSH but I can't create a cron job to implement the command.

Could someone help please?

Thanks
Nick

Re: Auto updating music library

PostPosted: 12 Feb 2018, 18:58
by ianhaynes
Have you tried the Auto Update setting on the MPD page, from the menu?

Ian

Re: Auto updating music library

PostPosted: 13 Feb 2018, 09:27
by Nick.Moshulu
Yes I have tried that but it isn't working

Re: Auto updating music library

PostPosted: 13 Feb 2018, 13:08
by hondagx35
Hi Nick.Moshulu,

i checked the autoupdate on my latest RP2/3 image and it works like it should.
There are several reasons for your issues:
- permissions
- mpd only checks changes in file date, so retagged files are mostly not detected.

I know what command to use via SSH but I can't create a cron job to implement the command.

Could someone help please?


I would do it the systemd way:
create these two files in /usr/lib/systemd/system

mpd-update-db.timer
Code: Select all
[Unit]
Description=Run mpd database update every 15 minutes

[Timer]
OnUnitActiveSec=15m

[Install]
WantedBy=timers.target


mpd-update-db.service
Code: Select all
[Unit]
Description=Run mpd database update every 15 minutes

[Service]
ExecStart=/usr/bin/mpc update

[Install]
WantedBy=multi-user.target


then run this command
Code: Select all
systemctl enable --now mpd-update-db.timer


with this command you can check the state
Code: Select all
systemctl list-timers


Frank

Re: Auto updating music library

PostPosted: 13 Feb 2018, 15:39
by Nick.Moshulu
Hi Frank

When getting the list of timers, under next, left, last and past it just has n/a.

is that normal?

Thanks
Nick

Re: Auto updating music library

PostPosted: 13 Feb 2018, 15:47
by hondagx35
Hi Nick,

please check:
Code: Select all
systemctl status mpd-update-db.timer


It is also possible that it needs a reboot.

Frank

Re: Auto updating music library

PostPosted: 13 Feb 2018, 16:04
by Nick.Moshulu
Hi Frank

I have rebooted the Pi and it looks like the mpd isn't booting up.

any ideas?

Should I reinstall it completely and try again?

Thanks
Nick

Re: Auto updating music library

PostPosted: 13 Feb 2018, 16:19
by Nick.Moshulu
Hi Frank

I went to dev and restarted mpd and that got that working again but it still says n/a.

I ran the code which says active (elapsed)
Code: Select all
systemctl status mpd-update-db.timer


Thanks
Nick

Re: Auto updating music library

PostPosted: 14 Feb 2018, 11:29
by Nick.Moshulu
I sorted the problem.
Use this for mpd-update-db.timer
Code: Select all
Unit]
Description=Run mpd database update every 15 minutes

[Timer]
OnBootSec=10min
OnUnitActiveSec=1d

[Install]
WantedBy=timers.target


and use this for mpd-update-db.service
Code: Select all
[Unit]
Description=Run mpd database update everyday

[Service]
ExecStart=/usr/bin/mpc update

[Install]
WantedBy=multi-user.target

Re: Auto updating music library

PostPosted: 04 Mar 2018, 10:58
by Stephane
Hello,

I have two RuneAudio systems running at home and both have the same configuration (it would be great is they could share the same MPD database!) but yesterday I found that one system did not update its database. The only difference between the two systems is that one was rebooted and I saw that the timers did not start as expected:
Code: Select all
systemctl list-timers -all
NEXT                         LEFT     LAST                         PASSED  UNIT                         ACTIVATES
Sun 2018-03-04 19:26:53 CET  8h left  Sat 2018-03-03 19:26:53 CET  15h ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Mon 2018-03-05 00:00:00 CET  13h left Sun 2018-03-04 00:00:05 CET  10h ago shadow.timer                 shadow.service
n/a                          n/a      n/a                          n/a     mpd-update-db.timer          mpd-update-db.service

No matter what I did it did not triggered the mpd timer. Then I found that this argument in the mpd-update-db.timer did the trick:
Code: Select all
[Timer]
Persistent=true

Just do a system daemon-reload (and maybe a systemctl restart --now mpd-update-db.timer) and MPD is updating its databse as expected.