In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you how to use the Linux system date command. The content is simple and easy to understand. The organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn how to use the Linux system date command.
To display the system date, simply enter:
$ date Thu Dec 5 22:55:41 WIB 2013 Format Display dates in many formats. If you don't like the default format, you can change it. You may be thinking,"Why do I need to change the format? The default output is sufficient for me. "
Yes, you're right, but when you're programming, the default output may not meet your needs, so you need some custom output.
RFC 2822 date and time output format $date-R Thu, 05 Dec 2013 23:40:53 +0700RFC 2822 format looks like this: Day, Day-Month-Year, Hour: Minute: Seconds Time Zone
Time zone +0700 is equivalent to GMT +7.
By default, date uses the time zone defined in/etc/localtime. Valid time zone data is defined in/usr/share/timezones.
Display or set Coordinated Universal Time On Wikipedia, UTC means
The world's major clocks and time standards. This is one of several very close substitutes for Green's position standard time.
Display date and time in UTC, using the-u parameter
$ date -u Thu Dec 5 16:45:58:UTC 2013 Use formatting options To customize your date format, use the plus sign (+)
$ date +"Day : %d Month : %m Year : %Y" Day: 05 Month: 12 Year: 2013 $ date +%D 12/05/13%D format is year/month/day format.
You can print the name of the date if you want. Here are some examples:
$ date +"%a %b %d %y" Fri 06 Dec 2013 $ date +"%A %B %d %Y" Friday December 06 2013 $ date +"%A %B %d %Y %T" Friday December 06 2013 00:30:37 $ date +"%A %B-%d-%Y %c" Friday December-06-2013 12:30:37 AM WIB has many other date formats. Just type:
$ date-help or
$ man date to display the syntax and parameters of the date command.
Basically, the date command translates all formats that begin with a percent sign (%) and outputs everything inside quotation marks ("").
Set system date and time Normally, you want your system date and time to be set automatically. If for some reason you want to modify it manually, we can use this command.
# date-set="20140125 09:17:00" This will set your current system date and time to January 25, 2014 and 09:17:00 AM. Note that you must have root privileges to do this. Otherwise you will get such a mistake.
date: cannot set date: Operation not permitted Sat Jan 25 09:17:00 WIB 2014 Reset your time If you want to reset your system date and time to their original values, you can use this trick.
# hwclock Fri 06 Dec 2013 03:44:10 AM WIB -0.314082 seconds This time sets your system date and time to what the output of the hwclock command looks like.
Use the date command in scripts Remember I said earlier why you need to change the date output? One answer is that you may need to program. Let's look at an example under bash scripts.
$ vi display.date #! /bin/bash DATETIME=$(date +"DATE: %a %b-%d-%Y TIME: %T WEEK NUMBER: %W") echo $DATETIME Save and run it:
$ ./ display.date DATE : Fri Dec-06-2013 TIME: 03:08:19 WEEK Number :40 If you find a permission denied error message, enter:
$ chmod 755 display.date Another example of using date in your backup process is using date in your backup process.
$ date +%F 2013-12-06 $ tar zcfv /daily_backup/backup-`date +%F`.tar.gz /home/pungki/Documents It compresses the folder/home/pungki/Documents into a file backup-2013-12-06.tar.gz located in the/daily_backup folder. To embed other commands on the command line by "command," this character is not a single quotation mark, but the symbol with the same key as the tilde ~.
The above is "Linux system date command how to use" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.