I have the following: server pi and client pi both running latest update version Raspbian Stretch

I have a .sh script on the client pi to update the time from my server pi. When I run this manually it works but i'm battling to have this process automated on client pi reboot.

Manually running:

root@MediaClient:/etc# date +%Y%m%d%T -s "`ssh root@ 'date "+%Y%m%d %T"'`"
root@'s password:

my rc.local looks like this:

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"

sh /BBTV/sh/Startup.sh

exit 0

I made sure rc.local is executable:

root@MediaClient:/etc# ls -l /etc/rc.local
-rwxr-xr-x 1 root root 444 Sep 24 16:31 /etc/rc.local

I made sure rc.local has a shebang line:

root@MediaClient:/etc# head -n1 /etc/rc.local
#!/bin/sh -e

what am I missing to do? Any help will be appreciated.


The answer was right there... my script to set the correct gateway didn't run... so this in turn didn't point the startup script to the correct gateway. Raspbian Stretch has a default gateway and that was the problem. Once I set the gateway my script ran perfectly.

  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Dec 11 '19 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.