1.显示当前时间,格式: 2016-06-18 10:20:30
[root@localhost ~]# date "+%F %H:%M:%S"
2020-08-07 15:52:18
2.显示前天是星期几
[root@localhost ~]# date -d "-2 day" +%A
Wednesday
3.设置当前日期为2019-08-07 06:05:10
[root@localhost ~]# date
Fri Aug 7 15:54:15 CST 2020
[root@localhost ~]# date -d "2019-08-07 06:05:10"
Wed Aug 7 06:05:10 CST 2019
4.在本机字符终端登录时,除显示原有信息外,再显示当前登录终端号,主机名和当前时间
[root@localhost ~]# vim /etc/issue
##增加以下三行。
# tty: \l
# hostname: \n
# time: \t
5.今天18: 30自动关机,并提示用户
[root@localhost ~]# shutdown 15:40 "Alarm : System will shutdown in 15:40."
Shutdown scheduled for Sat 2020-08-08 15:40:00 CST, use 'shutdown -c' to cancel.