I have to check the time in linux terminal. 我要检查linux终端的时间。
What is the command for getting date and time in Linux terminal ? 在Linux终端中获取日期和时间的命令是什么?
Is there any way in which we can set custom function ? 有什么方法可以设置自定义功能吗?
#1楼
参考:https://stackoom.com/question/1FRzD/如何在终端中获取当前日期和时间并在终端中为其设置自定义命令-关闭
#2楼
You can use date
to get time and date of a day: 您可以使用date
来获取一天的时间和日期:
[pengyu@GLaDOS ~]$date
Tue Aug 27 15:01:27 CST 2013
Also hwclock
would do: hwclock
也会:
[pengyu@GLaDOS ~]$hwclock
Tue 27 Aug 2013 03:01:29 PM CST -0.516080 seconds
For customized output, you can either redirect the output of date
to something like awk
, or write your own program to do that. 对于自定义输出,您可以将date
输出重定向到类似awk
,或者编写自己的程序来执行此操作。
Remember to put your own executable scripts/binary into your PATH
(eg /usr/bin) to make it invokable anywhere. 记得将自己的可执行脚本/二进制文件放入PATH
(例如/ usr / bin),以使其可以在任何地方调用。
However, I don't think this is a good question for StackOverflow. 但是,我认为这对StackOverflow来说不是一个好问题。
#3楼
The command is date
命令是date
To customise the output there are a myriad of options available, see date --help
for a list. 要自定义输出,可以使用多种选项,请参阅date --help
帮助列表。
For example, date '+%A %W %Y %X'
gives Tuesday 34 2013 08:04:22
which is the name of the day of the week, the week number, the year and the time. 例如, date '+%A %W %Y %X'
给出Tuesday 34 2013 08:04:22
这是星期几的名称,星期数,年份和时间。