Skip to content

Latest commit

 

History

History
145 lines (102 loc) · 2.97 KB

File metadata and controls

145 lines (102 loc) · 2.97 KB
  1. Sync Date Time in Alpine

debian ubuntu

sudo timedatectl set-timezone Asia/Tehran
sudo ln -sf /usr/share/zoneinfo/Asia/Tehran /etc/localtime
sudo hwclock --systohc

Time and Timezone

  • Alpine 👌 ⏰ ✔️
# apk add --no-cache tzdata
# ls /usr/share/zoneinfo
# cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime
# echo "Asia/Tehran" >  /etc/timezone

### You can now remove the other timezones
# apk del tzdata

Sync time apline in VM

برای سینک کردن تایم بعد از اسلیپ خارج شدن کامپیوتر باید این دستورات را اجرا کنید که اتوماتیک تایم سینک شود install virtualbox

apk add virtualbox-guest-additions

run cmd

 /usr/sbin/VBoxService --timesync-set-start
  • ubuntu 👌 ⏰✔️
# cat /etc/timezone
# timedatectl list-timezones
# timedatectl set-timezone your_time_zone -> for exam Asia/Tehran
# timedatectl

⏰ Date Time CMD

date +%Y%m%d -s "20150422"
Set time from the command line
date +%T -s "11:14:00"
Set time and date from the command line
date -s "19 APR 2012 11:14:00"

or

date -s "2013-11-19 15:11:40"
Linux check date from command line
date
time zone query
date +%Z
UTM Time
date --utc
 Sat Sep  5 07:57:50 UTC 2015

I always keep my hardware clocks set to UTC/GMT. This maintains my clocks uniformly without any worries about "Daylight Savings Time". This is important, because when you set the hardware clock from the system clock (kept by the Linux kernel), you need to know if this is the case. To set the hardware clock from the system clock, leaving the hardware clock in UTC, enter the following:

 hwclock --systohc --utc

Change Time Zone

Source :
rm /etc/localtime
ln -s /usr/share/zoneinfo/Iran /etc/localtime

for check

ls -al|grep localtime
 lrwxrwxrwx  1 root root      24 Apr 22 10:02 localtime -> /usr/share/zoneinfo/iran

Setting the system time using the date command does not automatically synchronize the RTCs. Use the hwclock command after entering the date command to synchronize an RTC with the updated system time:

hwclock -w

Update from the command line against a time server You can update the clock manually, without the need of the daemon with ntpdate

ntpdate 129.6.15.28

Using the date and hwclock Command Use these two commands to manipulate the system clock and hardware clock directly. From http://busybox.net/downloads/BusyBox.html#hwclock .

hwclock -r
(Show hardware clock time)
hwclock -w
(Set hardware clock to system time)
hwclock -s
(Set system time from hardware clock)
-f FILE can be used to specify a particular RTC device (e.g. /dev/rtc2).