تنظیم ساعت و تاریخ در لینوکس
این آموزش برای سیستم های لینوکسی که با استفاده از پایه متنی (سرورهای لینوکسی) از طریق putty یا ssh میخواهند ساعت و تاریخ سرورشان را تنظیم کنند بسیار ضروری است.
برای نمایش تاریخ و ساعت از کد زیر استفاده می کنیم.
date
که برای مثال چنین نمایشی به شما می دهد
Thu Jun 12 10:12:04 EDT 2014
حال برای تنظیم کردن از مثال زیر استفاده می کنیم.
date –set=”Thu Jun 12 07:13:00 EDT 2014″
برای ست کردن timezone در سنت اوس یا فدورا یا … به این شکل عمل می کنیم که شهر مورد نظر رو به timezone اصلی سیستم کپی می کنیم و با آپدیت کردن از طریق ntp ساعت دقیق رو تنظیم می کنیم.
cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime
yum install ntp
nano /etc/ntpd.conf
حال در فایل تنظیمات ntp مقدیر زیر را کپی می کنیم.
# With the default settings below, ntpd will only synchronize your clock.
#
# For details, see:
# - the ntp.conf man page
# - http://support.ntp.org/bin/view/Support/GettingStarted
# - https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon
# Associate to public NTP pool servers; see http://www.pool.ntp.org/
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
# Only allow read-only access from localhost
restrict default noquery nopeer
restrict 127.0.0.1
restrict ::1
# Location of drift and log files
driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log
# NOTE: If you run dhcpcd and have lines like 'restrict' and 'fudge' appearing
# here, be sure to add '-Y -N' to the dhcpcd_ethX variables in /etc/conf.d/net
و بعد از آن دستور آپدیت را اجرا می کنیم.
ntpdate 129.6.15.28
موفق باشید