Linux Set Date and Time From a Command Prompt
2015-05-13 21:47
309 查看
Linux Set Date and Time From a Command Prompt
by Vivek Gite on October 2, 2006 · from :http://www.cyberciti.biz/faq/howto-set-date-time-from-linux-command-prompt/How can I set the system date and time from the command prompt (bash shell)? I don't have GUI installed and I am login over ssh session. How can I set date under Linux operating systems?
Use the date command to display the current date and time or set the system date / time over ssh session. You can also run the date command from X terminal as root user.
This is useful if the Linux server time and/or date is wrong, and you need to set it to new values from the shell prompt.
You must login as root user to use date command.
Linux Set Date
Use the following syntax to set new data and time:date --set="STRING"
For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
# date -s "2 OCT 2006 18:00:00"
OR
# date --set="2 OCT 2006 18:00:00"
You can also simplify format using following syntax:
# date +%Y%m%d -s "20081128"
Linux Set Time
To set time use the following syntax:# date +%T -s "10:13:13"
Where,
10: Hour (hh)
13: Minute (mm)
13: Second (ss)
Use %p locale’s equivalent of either AM or PM, enter:
# date +%T%p -s "6:10:30AM" # date +%T%p -s "12:10:30PM"
See also:
You can also set new timzone using this mini-howto.相关文章推荐
- Linux Find Out Last System Reboot Time and Date Command
- Download and watch YouTube videos from Linux shell prompt
- 从 varchar 数据类型到 datetime 数据类型的转换产生一个超出范围的值/Conversion failed when converting date and/or time from c
- [Linux]Date and Time Commands
- 'Conversion failed when converting date and/or time from character string.DB-Lib error message 241,
- Chapter 5: PS1, PS2, PS3, PS4 and PROMPT_COMMAND __Linux 101 Hacks
- Mysql日期时间类型(DATE,DATETIME,TIMESTAMP)和函数及与linux系统时间之间的转换(UNIX_TIMESTAMP、FROM_UNIXTIME)
- Date-time Conversion Functions to and from Character
- time zone date set
- Linux Command Line and....ch5(理解shell)
- 《Realtime and Robust Hand Tracking from Depth》读书笔记2
- List environment variables from Command Prompt
- You are *required* to use the date.timezone setting or the date_default_timezone_set() function.
- (Blue) Taxi Destination and Trip Time Prediction from Partial Trajectories (阅读笔记)20171206
- Linux Command Line and....ch12(使用结构化命令)
- 关于 2012-07-11 00:00:00 is not a valid date and time的错误
- Get current time and date on Android
- JAVA Current date and time
- Boost::Date_time库和time_from_string()函数的使用
- 【zabbix】问题 Time zone for PHP is not set (configuration parameterdate.timezone)