[Linux]时间相关命令

来源:互联网 发布:日本烘焙大师 知乎 编辑:程序博客网 时间:2024/05/22 11:44

查看系统时间

[mycentos64@localhost so]$ date --helpUsage: date [OPTION]... [+FORMAT]  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]Display the current time in the given FORMAT, or set the system date.  -d, --date=STRING         display time described by STRING, not `now'  -f, --file=DATEFILE       like --date once for each line of DATEFILE  -r, --reference=FILE      display the last modification time of FILE  -R, --rfc-2822            output date and time in RFC 2822 format      --rfc-3339=TIMESPEC   output date and time in RFC 3339 format.                            TIMESPEC=`date', `seconds', or `ns' for                            date and time to the indicated precision.  -s, --set=STRING          set time described by STRING  -u, --utc, --universal    print or set Coordinated Universal Time      --help     display this help and exit      --version  output version information and exitFORMAT controls the output.  The only valid option for the second formspecifies Coordinated Universal Time.  Interpreted sequences are:  %%   a literal %  %a   locale's abbreviated weekday name (e.g., Sun)  %A   locale's full weekday name (e.g., Sunday)  %b   locale's abbreviated month name (e.g., Jan)  %B   locale's full month name (e.g., January)  %c   locale's date and time (e.g., Thu Mar  3 23:05:25 2005)  %C   century; like %Y, except omit last two digits (e.g., 21)  %d   day of month (e.g, 01)  %D   date; same as %m/%d/%y  %e   day of month, space padded; same as %_d  %F   full date; same as %Y-%m-%d  %g   last two digits of year of ISO week number (see %G)  %G   year of ISO week number (see %V); normally useful only with %V  %h   same as %b  %H   hour (00..23)  %I   hour (01..12)  %j   day of year (001..366)  %k   hour ( 0..23)  %l   hour ( 1..12)  %m   month (01..12)  %M   minute (00..59)  %n   a newline  %N   nanoseconds (000000000..999999999)  %p   locale's equivalent of either AM or PM; blank if not known  %P   like %p, but lower case  %r   locale's 12-hour clock time (e.g., 11:11:04 PM)  %R   24-hour hour and minute; same as %H:%M  %s   seconds since 1970-01-01 00:00:00 UTC  %S   second (00..60)  %t   a tab  %T   time; same as %H:%M:%S  %u   day of week (1..7); 1 is Monday  %U   week number of year, with Sunday as first day of week (00..53)  %V   ISO week number, with Monday as first day of week (01..53)  %w   day of week (0..6); 0 is Sunday  %W   week number of year, with Monday as first day of week (00..53)  %x   locale's date representation (e.g., 12/31/99)  %X   locale's time representation (e.g., 23:13:48)  %y   last two digits of year (00..99)  %Y   year  %z   +hhmm numeric timezone (e.g., -0400)  %:z  +hh:mm numeric timezone (e.g., -04:00)  %::z  +hh:mm:ss numeric time zone (e.g., -04:00:00)  %:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)  %Z   alphabetic time zone abbreviation (e.g., EDT)By default, date pads numeric fields with zeroes.The following optional flags may follow `%':  - (hyphen) do not pad the field  _ (underscore) pad with spaces  0 (zero) pad with zeros  ^ use upper case if possible  # use opposite case if possibleAfter any flags comes an optional field width, as a decimal number;then an optional modifier, which is eitherE to use the locale's alternate representations if available, orO to use the locale's alternate numeric symbols if available.Report bugs to <bug-coreutils@gnu.org>.

查看文件信息

[mycentos64@localhost so]$ stat --helpUsage: stat [OPTION] FILE...Display file or file system status.  -L, --dereference     follow links  -Z, --context         print the security context information if available  -f, --file-system     display file system status instead of file status  -c  --format=FORMAT   use the specified FORMAT instead of the default;                          output a newline after each use of FORMAT      --printf=FORMAT   like --format, but interpret backslash escapes,                          and do not output a mandatory trailing newline.                          If you want a newline, include \n in FORMAT.  -t, --terse           print the information in terse form      --help     display this help and exit      --version  output version information and exitThe valid format sequences for files (without --file-system):  %a   Access rights in octal  %A   Access rights in human readable form  %b   Number of blocks allocated (see %B)  %B   The size in bytes of each block reported by %b  %d   Device number in decimal  %D   Device number in hex  %f   Raw mode in hex  %F   File type  %g   Group ID of owner  %G   Group name of owner  %h   Number of hard links  %i   Inode number  %n   File name  %N   Quoted file name with dereference if symbolic link  %o   I/O block size  %s   Total size, in bytes  %t   Major device type in hex  %T   Minor device type in hex  %u   User ID of owner  %U   User name of owner  %x   Time of last access  %X   Time of last access as seconds since Epoch  %y   Time of last modification  %Y   Time of last modification as seconds since Epoch  %z   Time of last change  %Z   Time of last change as seconds since EpochValid format sequences for file systems:  %a   Free blocks available to non-superuser  %b   Total data blocks in file system  %c   Total file nodes in file system  %d   Free file nodes in file system  %f   Free blocks in file system  %C   Security context in SELinux  %i   File System ID in hex  %l   Maximum length of filenames  %n   File name  %s   Block size (for faster transfers)  %S   Fundamental block size (for block counts)  %t   Type in hex  %T   Type in human readable formNOTE: your shell may have its own version of stat, which usually supersedesthe version described here.  Please refer to your shell's documentationfor details about the options it supports.Report bugs to <bug-coreutils@gnu.org>.

修改文件时间

[mycentos64@localhost so]$ touch --helpUsage: touch [OPTION]... FILE...Update the access and modification times of each FILE to the current time.Mandatory arguments to long options are mandatory for short options too.  -a                     change only the access time  -c, --no-create        do not create any files  -d, --date=STRING      parse STRING and use it instead of current time  -f                     (ignored)  -m                     change only the modification time  -r, --reference=FILE   use this file's times instead of current time  -t STAMP               use [[CC]YY]MMDDhhmm[.ss] instead of current time  --time=WORD            change the specified time:                           WORD is access, atime, or use: equivalent to -a                           WORD is modify or mtime: equivalent to -m      --help     display this help and exit      --version  output version information and exitNote that the -d and -t options accept different time-date formats.If a FILE is -, touch standard output.Report bugs to <bug-coreutils@gnu.org>.
0 0
原创粉丝点击