Created
August 29, 2024 10:16
-
-
Save arsalanses/0420bfc558d8cc2976a003bf3014ae37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -xue | |
| # Synchronize the system clock with an NTP server | |
| sudo ntpdate pool.ntp.org | |
| # Get the current UTC time | |
| current_utc=$(date -u +"%Y-%m-%d %H:%M:%S") | |
| # Convert the current UTC time to a timestamp | |
| current_timestamp=$(date -d "$current_utc" +"%s") | |
| # Calculate the timestamp for UTC minus one hour | |
| new_timestamp=$((current_timestamp - 3600)) | |
| # Convert the new timestamp back to a date string | |
| new_date=$(date -d @$new_timestamp +"%Y-%m-%d %H:%M:%S") | |
| # Set the system date and time to the new date | |
| sudo timedatectl set-time "$new_date" | |
| echo "System date and time set to: $new_date" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment