Categories: Linux

How to change server timezone to Malaysia Time

Let’s say, you have setup a new server which is running either Ubuntu 20.04 or Centos7.9

And while setting up cron, you notice the date time need to be offset correctly to have the actual time locally.

How about we just change the server to use local timezone altogether.

Here is how to do it.

 

Firstly, check first if the timezone list already updated.

Step1 : Check current setting by issuing the following command.

timedatectl

example output: (if UTC)

Local time: Sun 2022-03-13 12:46:47 UTC
Universal time: Sun 2022-03-13 12:46:47 UTC
RTC time: Sun 2022-03-13 12:46:47
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no

 

Step2: Check the actual timezone string required for Kuala Lumpur

timedatectl list-timezones|grep Asia|grep Kuala

..

Asia/Kuala_Lumpur

 

Step3: Set to the target timezone above Asia/Kuala_Lumpur

sudo timedatectl set-timezone Asia/Kuala_Lumpur

 

 

Step4: Re-check again

timedatectl

example output:

Local time: Sun 2022-03-13 20:49:41 +08
Universal time: Sun 2022-03-13 12:49:41 UTC
RTC time: Sun 2022-03-13 12:49:41
Time zone: Asia/Kuala_Lumpur (+08, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a

Step 5: restart crond , httpd and check the logs

sudo service crond restart

sudo service mysqld restart

 

Step 6: Check logs

tail -f /var/log/apache/access.log

example:
52.77.255.203 - - [13/Mar/2022:20:36:44 +0800] "GET //i.php HTTP/1.1" 404 10072 "-" "python-requests/2.27.1"
52.77.255.203 - - [13/Mar/2022:20:36:44 +0800] "GET //infos.php HTTP/1.1" 404 10080 "-" "python-requests/2.27.1"
52.77.255.203 - - [13/Mar/2022:20:36:44 +0800] "GET //linusadmin-phpinfo.php HTTP/1.1" 404 10106 "-" "python-requests/2.27.1"
52.77.255.203 - - [13/Mar/2022:20:36:44 +0800] "GET //dashboard/phpinfo.php HTTP/1.1" 404 10104 "-" "python-requests/2.27.1"

Done.

Namran Hussin

a soft spoken guy... with exceptional interest in computers and technology. I love to learn new thing and also love to break thing for the sake of learning.. but I do abide to the self-imposed limitation or certain thing such as social thing in life, thing can be done and thing that must be avoided at whatever cost such as drug,illegal tracking, smoke,illicit activity..etc.muahahaha let's share what we had in this short term of the life.! make it worth of the living.~

Leave a Comment
Share
Published by
Namran Hussin

Recent Posts

How you can speak with clarity and influence

Here are five key communication skills that help you speak with clarity and influence: Speak…

7 months ago

? Man360 Academy Q&A Session Video Access – Empower Your Masculine Growth Journey

Are you ready to unlock your full potential as a man?Discover powerful insights, real-life transformations,…

1 year ago

A note to remember

One day we will set aside one whole day to review the whole lesson we…

1 year ago

Dev Fest KL 2024

Last weekend, 07/12/2024 I managed to join Dev Fest Kuala Lumpur 2024, organized by Google…

1 year ago

TIPS BACAAN AL-QURAN

TIPS BACAAN AL-QURANOleh: Dr. Muhd al-Muhaysni.1. Jangan engkau berikan (fokus membaca) al-Quran pada lebihan waktumu…

2 years ago

Selawat 300 ribu kali

Selawat yang ringkas, yang mana apabila kamu membacanya satu kali sebanding 100 ribu kali, jadi…

2 years ago