Timezone Alignment Level 1 Linux KodeKloud Engineer Task Success Sshpass script to Automate task

Ticker

6/recent/ticker-posts

Timezone Alignment Level 1 Linux KodeKloud Engineer Task Success Sshpass script to Automate task

 Question :  In the daily standup, it was noted that the timezone settings across the Nautilus Application Servers in the Stratos Datacenter are inconsistent with the local datacenter's timezone, currently set to America/Juneau.

Synchronize the timezone settings to match the local datacenter's timezone (America/Juneau).

Please Note :-  Perform the below commands based on your question  server,  user name & other details might differ . So please read task carefully before executing. All the Best 👍


Solution:  

1. With the help of sshpass command we can execute command from jump server

no need to login on any remote app servers.

thor@jumphost ~$ sshpass -p Ir0nM@n ssh -o StrictHostKeyChecking=no tony@stapp01 "echo Ir0nM@n  | sudo -S timedatectl" 

Warning: Permanently added 'stapp01' (ED25519) to the list of known hosts.

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.

[sudo] password for tony:                Local time: Mon 2025-08-04 08:21:49 UTC

           Universal time: Mon 2025-08-04 08:21:49 UTC

                 RTC time: n/a

                Time zone: Etc/UTC (UTC, +0000)

System clock synchronized: yes

              NTP service: n/a

          RTC in local TZ: no

thor@jumphost ~$

thor@jumphost ~$ sshpass -p Ir0nM@n ssh -o StrictHostKeyChecking=no tony@stapp01 "echo Ir0nM@n  | sudo -S timedatectl set-timezone America/Juneau"

[sudo] password for tony: thor@jumphost ~$ 

thor@jumphost ~$

thor@jumphost ~$ sshpass -p Ir0nM@n ssh -o StrictHostKeyChecking=no tony@stapp01 "echo Ir0nM@n  | sudo -S timedatectl" 

[sudo] password for tony:                Local time: Mon 2025-08-04 00:22:13 AKDT

           Universal time: Mon 2025-08-04 08:22:13 UTC

                 RTC time: n/a

                Time zone: America/Juneau (AKDT, -0800)

System clock synchronized: yes

              NTP service: n/a

          RTC in local TZ: no

thor@jumphost ~$ 


 2. Run Below command to change set Time zone or all other app servers  

Please note enter  zone define in your task

thor@jumphost ~$

sshpass -p Am3ric@ ssh -o StrictHostKeyChecking=no steve@stapp02 "echo Am3ric@  | sudo -S timedatectl set-timezone America/Juneau" 


thor@jumphost ~$

sshpass -p BigGr33n  ssh -o StrictHostKeyChecking=no banner@stapp03 "echo BigGr33n  | sudo -S timedatectl set-timezone America/Juneau" 


 3. Validate  the status on all the app server

thor@jumphost ~$

sshpass -p Am3ric@ ssh -o StrictHostKeyChecking=no steve@stapp02 "echo Am3ric@  | sudo -S timedatectl" 

thor@jumphost ~$

sshpass -p BigGr33n ssh -o StrictHostKeyChecking=no banner@stapp03 "echo BigGr33n  | sudo -S timedatectl" 



5.  Click on Finish & Confirm to complete the task successful

Happy Learning!!!!


Apart from this if you need more clarity,  I have made a  tutorial video on this , please go through and share your comments. Like and share the knowledge


Post a Comment

0 Comments

Latest Posts

Timezone Alignment Level 1 Linux KodeKloud Engineer Task Success  Sshpass script to Automate task