Index: scripts/date_time_set.sh =================================================================== diff -u --- scripts/date_time_set.sh (revision 0) +++ scripts/date_time_set.sh (revision 2a5e8882fa17faacf0c58b430f570cbe095265b5) @@ -0,0 +1,32 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file date_time_set.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 20-Apr-2021 +# @author (original) Behrouz NematiPour +# @date (original) 20-Apr-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile 'yyyy-mm-dd HH:MM:SS' [ntp:true|false]" + exit 0 +fi + +new_time="$1" +ntp_flag="${2:-false}" # Default to 'false' if not provided + +sudo timedatectl set-ntp "$ntp_flag" + +sudo date -s "$new_time" + +# set the hwclock from the system time +sudo hwclock -w