PDA

View Full Version : PcP reboot via http command



edwin2006
2019-03-30, 00:45
Since I noticed that it appears that the systemclock is only synchronized during boot I was wondering if it is possible to reboot pcp via http command as if you would manually make the selection.
My aim is to reboot pcp with lms via my domotica homeseer system.

Any other suggestions are welcome. My goal is to show accurate time on the SB systems.

Paul Webster
2019-03-30, 03:42
I have mine set to correct the time every 4 hours


On the Tweaks page in pCP ... scroll down to the cron section and add a custom one

0 */4 * * * /usr/bin/getTime.sh


If you still want to reboot then you will find an option to do that from the same area in pCP Tweaks section

Edited because my pCP was showing
4 * * /usr/bin/getTime.sh
which I think must have been wrong unless it is a special format ... so have edited it to be what is now shown and set it the same way on my pCP.

peterw
2019-03-30, 06:01
PcP includes an NTP daemon, have you tried just running it as on a normal Linux system? SSH in and you can run it with something like
sudo /usr/sbin/ntpd -p time.windows.com

Out of the box, the current PcP has a single NTP pool name in /etc/sysconfig/ntpserver so you could also use "-p $(cat /etc/sysconfig/ntpserver)" instead of "-p time.windows.com".

Why doesn't PcP run ntpd all the time? According to pippin, clock drift is bad for synchronized playback (https://forums.slimdevices.com/showthread.php?110197-LMS-Max-number-of-players-and-how-to-reduce-latency&p=937139#post937139), so it seems like NTP would be an especially good thing to run on PcP.

Paul Webster
2019-03-30, 06:08
The contents of getTime.sh ...



#!/bin/busybox ash
# bmarkus - 26/02/2014

NTPSERVER=$(cat /etc/sysconfig/ntpserver)
/usr/sbin/ntpd -q -p $NTPSERVER

paul-
2019-03-30, 06:09
Pretty sure you have an extra star in the every 4 hours

0 /4 * * * /usr/bin/getTime.sh

We just dont run a lot of daemons automatically, you can choose what you want.

peterw
2019-03-30, 06:22
We just dont run a lot of daemons automatically, you can choose what you want.

Would the recommended approach (for running ntpd all the time) be to put the ntpd command, without sudo, in one of the User Command slots on the Tweaks page in the web UI?

Paul Webster
2019-03-30, 06:23
*/4 seems to be correct perhaps there are alternate ways of doing the same thing.

paul-
2019-03-30, 06:53
Yes, just add to the user commands.

edwin2006
2019-03-30, 12:08
So the solution would be to add
0 /4 * * * /usr/bin/getTime.sh
In the tweaks section?

Btw I think that 4 hr is more than enough. Once a week would probably also sufficient since mine has drifted approximately 1 minute while running for months.

Greg Erskine
2019-03-30, 15:01
I would recommend some reading on the ntp protocol. There is a difference running it as a daemon or a cli command.

It should be noted that piCorePlayer usually follows the Tiny Core/piCore "way of doing things", we don't load stuff that is not used and we don't start processes unless there is a need for them.

Note that crond is not started by default, you need to use the web interface. If you are trying to use cron from the command line you need to ensure the cron bootcode is added and reboot.

edwin2006
2019-03-30, 16:01
Ok, now I'm lost again....
It's simply to solve a problem. Clock on SB touch shows incorrect time, wife complains. How to solve, beside manually reboot every now and then?

edwin2006
2019-03-30, 16:02
Ok, now I'm lost again....
It's simply to solve a problem. Clock on SB touch shows incorrect time, wife complains. How to solve, beside manually reboot every now and then?

edwin2006
2019-03-30, 16:08
Sorry, double post.

peterw
2019-03-30, 16:26
Sorry, double post.

You're all set now, right? Two options: run cron daemon continuously and configure it to knock the clock back into shape every so often, or run the NTP daemon continuously and have the clock be corrected more often and subtly.

BTW, post-reboot it seems to work to put "/usr/sbin/ntpd -p time.windows.com" into one of the user command slots. I figure Microsoft has gotten enough money from me and most everybody else, they can help me keep my clocks synced. :-)

paul-
2019-03-30, 16:47
How does the SB Touch get its time?

And that cron command you posted earlier goes in th custom cron setting

peterw
2019-03-30, 18:23
How does the SB Touch get its time?

Squeezeplay gets the time from LMS once an hour. See lines 480-509 of SqueezeboxFab4Applet.lua (https://github.com/ralph-irving/squeezeplay/blob/73a0d54e5644c53f73f401079621731fd5af9435/src/squeezeplay_fab4/share/applets/SqueezeboxFab4/SqueezeboxFab4Applet.lua)

(I always thought that was clever: since Touch/Radio/Controller can be assumed to have connectivity to LMS, don't bother with NTP. Not so great for PcP though since sometimes PcP itself is the LMS host.)

paul-
2019-03-30, 19:48
I have a pCP device with over 1000 days of uptime, itís clock is fine, I just sync it once a day.

edwin2006
2019-03-30, 23:16
Oh, oeps. Mis understanding, I was talking about lms part. I figured out that the player got the time from lms and that the time on lms was only corrected during boot of pi. That's why the question.
Will try cron solution.

Rnee
2019-04-01, 02:42
The way I'm doing this is through the webinterface: [Main Page] => 'Extras' => [Bootcodes] => 'ntpserver'

Jeff07971
2019-04-01, 02:44
The way I'm doing this is through the webinterface: [Main Page] => 'Extras' => [Bootcodes] => 'ntpserver'

This still only sets the time at boot or when you run "gettime.sh"

Jeff

Rnee
2019-04-01, 04:18
Tnx Jeff!

So in my case: by adding the cron job, will the time come from the NTP server filled in bootcodes?
What is that first slash in
0 */4 * * * /usr/bin/getTime.sh

Jeff07971
2019-04-01, 04:32
Tnx Jeff!

So in my case: by adding the cron job, will the time come from the NTP server filled in bootcodes?
What is that first slash in
0 */4 * * * /usr/bin/getTime.sh

Had to check but Yes !

Before setting ntpserver:-

27074

After setting tp 10.44.4.249

27075

The slash means repeat every 4 hours (/2 would be every two)

Jeff

Rnee
2019-04-01, 05:35
Thanks again!