Time based commands :

  • cal - displays a calendar, usually of current month, but it is possible to display the whole year or even a different month or year. The month range is specified by a numeric value in the range 1-12. Years may be specified in the range 1 - 9999. It is important to state the full year number, as 89 will generate the year 89 not 1989. If a single number argument is specified, it will assumed to be the year.

    Syntax :

    cal [[month] year]

    Exercise :
    
    #( Display Current month )
    cal
    
    #( Current year, pipe to less to make viewing easier. )
    cal 2007 | less
    
    #( cal finds months by number, display April of 1983 )
    cal  4 1983
    
    #( try your birth-date and year )
    

  • date - display the current date. The default display lists day, Date, time, time zone and year. However, a variety of options allow you to change the format of the output. see the man page for formatting options.

    Exercise:
    
    #( Print current local date and time. )
    date
    
    #( Print the current day of the year and hour as numeric values. )
    date "+%j%H"
    
    #( Print date in mm/dd/yyyy form. )
    date "+%D"
    
    #( print Greenwich or UTC time. )
    date -u
    
    

    Note that the format string is quoted and the + must start the format string.

  • time - time reports the run time of a specified command sequence. Invoke time with the command sequence to time as an argument. time, in turn, invokes the command sequence. The command sequence may include piping between multiple commands and the time reported will be for the complete command sequence.

    time generates three times, the real time between start and end of program execution, the system time which is CPU time used for kernel support, such as writing to screen or file i/o, and user CPU time, which is the time running the command's instructions.

    Older versions of time have been outpaced by the CPU speed and often return zero for most values. Newer systems have corrected this. On our Linux system, time returns minutes, seconds and 1000ths of seconds.

    #( Run time on the top command. Let top run for 2 or 3 refreshes before quitting. )

    time top

    Command List