总结了一下cal、date、uptime三个命令的用法。
cal(AIX版本)命令
cal命令的功能是显示某年某月的日历。
语法如下:
cal [ [ Month ] Year ]
说明:
(1)这是AIX系统上的cal语法,其他版本的unix系统可能会略有出入。
(2)参数Year应该为四位数字(比如:2010),不能使用两位数字。
(3)Year的取值范围为1–9999;Month的取值范围为1–·12。如果没有指定Year和Month参数,则显示当前月份的日历。
(4)如果只输入一个参数,那么该参数将被当做year使用,并展示指定年份的日历。
date(AIX版本)命令
date命令的功能是显示和设置系统日期和时间。
如果date命令后面没有任何参数,或者参数以 [ + ] 开始,那么该命令就是向标准输出显示日期和时间。
否则的话,date命令就是设置系统时间。当然,并是不是所有用户都可以设置系统时间,只有root用户才可以这么做。root用户在设置系统时间的时候也需要注意:当有其他用户登录系统的情况下不要使用该命令进行时间设置。
语法格式:
显示时间和日期的语法如下:
date [ -u ] [ +FieldDescriptor … ]
设置时间和日期的语法如下:
date [ -n ] [ -u ] [ Date ] [ +FieldDescriptor … ]
参数说明:
-u
Displays or sets the time in Coordinated Universal Time (CUT).
-n
Does not set the time globally on all machines in a local area network that have their clocks synchronized.
可用的时间格式字符:
%a
Displays the locale’s abbreviated weekday name.
%A
Displays the locale’s full weekday name.
%b
Displays the locale’s abbreviated month name.
%B
Displays the locale’s full month name.
%c
Displays the locale’s appropriate date and time representation. This is the default.
%C
Displays the first two digits of the four-digit year as a decimal number (00-99). A year is divided by 100 and truncated to an integer.
%d
Displays the day of the month as a decimal number (01-31). In a two-digit field, a 0 is used as leading space fill.
%D
Displays the date in the format equivalent to %m/%d/%y.
%e
Displays the day of the month as a decimal number (1-31). In a two-digit field, a blank space is used as leading space fill.
%h
Displays the locale’s abbreviated month name (a synonym for %b).
%H
Displays the hour (24-hour clock) as a decimal number (00-23).
%I
Displays the hour (12-hour clock) as a decimal number (01-12).
%j
Displays the day of year as a decimal number (001-366).
%k
Displays the 24-hour-clock hour clock as a right-justified, space-filled number ( 0 to 23).
%m
Displays the month of year as a decimal number (01-12).
%M
Displays the minutes as a decimal number (00-59).
挑了几个常用的,完整版见 [ man date ] 。
示例(显示日期和时间):
用简写格式显示今天是星期几
crm1:iweb:/iweb>date +%a
Wed
用完整格式显示今天是星期几
crm1:iweb:/iweb>date +%A
Wednesday
以下是AIX帮助手册自带的一个设置系统时间的示例:
date 0217142590
For a system using CST as its time zone, this sets the date and time to Sat Feb 17 14:25:00 CST 1990. Note: You must have root authority to
change the date and time.
如果非root用户想要设置系统时间的话会提示:
date: bind: The file access permissions do not allow the specified action.
date: 0551-003 You must be root to change the date.
==========================
uptime命令
uptime命令显示系统已经运行了多长时间,它依次显示下列信息:
现在时间、系统已经运行了多长时间、目前有多少登录用户、系统在过去的1分钟、5分钟和15分钟内的平均负载。
该命令的一般格式为: uptime
看一个例子:
crm1:iweb:/iweb>uptime
04:11PM up 32 days, 3:21, 13 users, load average: 2.53, 2.66, 2.73
==========================
Sorry, the comment form is closed at this time.
No comments yet.