Check if date goes backwards
This commit is contained in:
parent
a093437703
commit
b2e25fca34
|
@ -1003,13 +1003,38 @@ make install
|
|||
If you get errors during the /configure/ stage then you may need to reboot so that some of the installed dependencies take effect.
|
||||
|
||||
#+BEGIN_SRC: bash
|
||||
editor /usr/bin/updatedate
|
||||
#+END_SRC
|
||||
|
||||
Add the following:
|
||||
|
||||
#+BEGIN_SRC: bash
|
||||
#!/bin/bash
|
||||
|
||||
TIMESOURCE=www.ptb.de
|
||||
LOGFILE=/var/log/tlsdate.log
|
||||
DATE_BEFORE=$(date)
|
||||
YEAR_BEFORE=$(echo $DATE_BEFORE | awk -F ' ' '{print $6}')
|
||||
/usr/bin/timeout 3 tlsdate -l -t -H $TIMESOURCE -p 443
|
||||
DATE_AFTER=$(date)
|
||||
YEAR_AFTER=$(echo $DATE_AFTER | awk -F ' ' '{print $6}')
|
||||
if [ "$YEAR_AFTER" -lt "$YEAR_BEFORE" ]; then
|
||||
echo "Incorrect date: $DATE_BEFORE -> $DATE_AFTER" >> $LOGFILE
|
||||
date -s "DATE_BEFORE"
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
Save and exit.
|
||||
|
||||
#+BEGIN_SRC: bash
|
||||
chmod +x /usr/bin/updatedate
|
||||
editor /etc/crontab
|
||||
#+END_SRC
|
||||
|
||||
Add the following near the top of the list of tasks.
|
||||
|
||||
#+BEGIN_SRC: bash
|
||||
*/15 * * * * root /usr/bin/timeout 3 tlsdate -l -t -H www.ptb.de -p 443
|
||||
*/15 * * * * root /usr/bin/updatedate
|
||||
#+END_SRC
|
||||
|
||||
Save and exit.
|
||||
|
|
Loading…
Reference in New Issue