Linux smart help
Thursday, May 3, 2012
HowTo: Get Current Time In Shell Script
H
ow do I get current server time in shell script?
You can use the date command as follows to print current time only:
date
+
"%T"
Sample outputs:
16:33:22
To store time to a shell variable, enter:
ow=
$
(
date
+
"%T"
)
echo
"Current time : $now"
See also:
man date
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment