You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might be of interest. I run this script once a day. It queries the card for the date and if it doesn't match, sets the date and time. It also runs regardless once a month just to keep the clock in check.
I had 2 cards with flat "Snaphat" batteries, so they needed a clock set not infrequently. Now it's just run to save me thinking about it. Replaced one with an P9617 and it has ntp, so the loop is still there.
#!/bin/bash # Won't set while web user or shell user logged in.
DATE=date +%m/%d/%Y
DAY=date +%d
# Set the clock if the date doesn't match or it's the first of the month. # The RTC does drift slightly, so this keeps it on track
for i in 192.168.2.231 ; do
IND=snmpwalk -v1 -cpublic $i 1.3.6.1.4.1.318.2.1.6.1 | cut -f2 -d'"'
if [ "$IND" != "$DATE" -o "$DAY" -eq 1 ] ; then
echo Dates don't match or 1st of the month
snmpset -cprivate -v1 $i 1.3.6.1.4.1.318.2.1.6.1.0 s "$DATE" > /dev/null
TIME=date +%H:%M:%S
snmpset -cprivate -v1 $i 1.3.6.1.4.1.318.2.1.6.2.0 s "$TIME" > /dev/null
fi;
done;
Sorry, I completely munged the formatting and have no idea how to fix the quoted bits. Anyway, you get the idea. SNMP works just fine for setting the clock.
The text was updated successfully, but these errors were encountered:
This might be of interest. I run this script once a day. It queries the card for the date and if it doesn't match, sets the date and time. It also runs regardless once a month just to keep the clock in check.
I had 2 cards with flat "Snaphat" batteries, so they needed a clock set not infrequently. Now it's just run to save me thinking about it. Replaced one with an P9617 and it has ntp, so the loop is still there.
#!/bin/bash
# Won't set while web user or shell user logged in.
DATE=
date +%m/%d/%Y
DAY=
date +%d
# Set the clock if the date doesn't match or it's the first of the month.
# The RTC does drift slightly, so this keeps it on track
for i in 192.168.2.231 ; do
IND=
snmpwalk -v1 -cpublic $i 1.3.6.1.4.1.318.2.1.6.1 | cut -f2 -d'"'
if [ "$IND" != "$DATE" -o "$DAY" -eq 1 ] ; then
echo Dates don't match or 1st of the month
snmpset -cprivate -v1 $i 1.3.6.1.4.1.318.2.1.6.1.0 s "$DATE" > /dev/null
TIME=
date +%H:%M:%S
snmpset -cprivate -v1 $i 1.3.6.1.4.1.318.2.1.6.2.0 s "$TIME" > /dev/null
fi;
done;
Sorry, I completely munged the formatting and have no idea how to fix the quoted bits. Anyway, you get the idea. SNMP works just fine for setting the clock.
The text was updated successfully, but these errors were encountered: