ubuntu 时间操作

来源:互联网 发布:淘宝抢拍器app苹果 编辑:程序博客网 时间:2024/06/03 19:45

显示日历

cal # 显示当月日历cal 2 2007 # 显示2007年2月的日历

显示农历

#sudo apt-get install lunardate '+%Y %m %d %H' |xargs lunar --utf8

设置日期

date -s mm/dd/yy

设置时间

date -s HH:MM

将时间写入CMOS

hwclock --systohc

查看CMOS时间

 hwclock --show

读取CMOS时间

hwclock --hctosys

从服务器上同步时间

sudo ntpdate ntp.ubuntu.comsudo ntpdate time.nist.gov

设置电脑的时区为上海

sudo dpkg-reconfigure tzdata

然后根据提示选择 Asia/Shanghai。这样在升级了 tzdata 包之后时区也是对的。

XP 和 Ubuntu 相差了 8 小时的时差

#关闭UTC,将当前时间写入CMOS。sudo sed -ie 's/UTC=yes/UTC=no/g' /etc/default/rcSsudo hwclock --systohc

将时间截转为时间

date -d@1234567890