[yinxd@centos7 etc]$ date +"%F %T"
2020-05-13 14:10:10
2、显示前天是星期几
# 缩写显示[yinxd@centos7 etc]$ date -d "-2day" +"%a"
Mon
# 完整显示[yinxd@centos7 etc]$ date -d "-2day" +"%A"
Monday
# 显示一周中的第几天,值为0-6,0表示星期天[yinxd@centos7 etc]$ date -d "-2day" +"%w"
1
3、设置当前日期为 2020-05-13 14:18:50
[yinxd@centos7 etc]$ sudodate -s "2020-05-13 14:18:50"[sudo] password for yinxd:
Wed May 13 14:18:50 CST 2020
[yinxd@centos7 etc]$ date
Wed May 13 14:18:52 CST 2020
4、在本机字符终端登录时,除显示原有信息外,再显示当前登录终端号,主机名和当前时间
# 编辑 /etc/issue 文件[root@centos7 ~]# vim /etc/issue# 增加以下几行内容
tty: \l
hostname: \n
time: \t
# /etc/issue 文件中相关用法,见 man agetty 中 ISSUE ESCAPES 章节[yinxd@centos7 ~]$ man agetty
5、今天 15:40 自动关机,并提示用户
[root@centos7 ~]# shutdown 15:40 "Alarm : System will shutdown in 15:40."
Shutdown scheduled for Wed 2020-05-13 15:40:00 CST, use 'shutdown -c' to cancel.
Broadcast message from root@centos7 (Wed 2020-05-13 15:29:35 CST):
Alarm : System will shutdownin 15:40.
The system is going down for power-off at Wed 2020-05-13 15:40:00 CST!