- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to get timestamp
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 03:33 AM
тАО04-08-2005 03:33 AM
I just need to get actual timestamp from the command line (or a shell). I need to get actual count of seconds since 1970. I can do it in C using time() function, but I was about to make a script and amazingly found out that I cannot find anything that would provide this output to me.
thanks for all ideas
Michal
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 03:43 AM
тАО04-08-2005 03:43 AM
Re: how to get timestamp
1112974908
lt09:/home/merijn 112 >
sh-2.05b$ STAMP=$(perl -e'print time')
sh-2.05b$ echo $STAMP
1112974980
sh-2.05b$
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 03:43 AM
тАО04-08-2005 03:43 AM
Re: how to get timestamp
EPOCH=$(perl -e 'print time()')
echo "Seconds since 1-Jan-1970 00:00:00 UTC = ${EPOCH}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 04:07 AM
тАО04-08-2005 04:07 AM
Re: how to get timestamp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 04:10 AM
тАО04-08-2005 04:10 AM
Re: how to get timestamp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 04:13 AM
тАО04-08-2005 04:13 AM
Re: how to get timestamp
lt09:/home/merijn 116 > perl -MTime::HiRes=time -le'print time'
1112976753.63035
lt09:/home/merijn 117 >
Microseconds? From a shell-builtin? Nahhh
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 04:15 AM
тАО04-08-2005 04:15 AM
Re: how to get timestamp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 04:17 AM
тАО04-08-2005 04:17 AM
Re: how to get timestamp
i wasn't questioning availability of perl. I just wanted to stress fact that the perl would have to be installed on the system where I intend to use this script. The thing is that I support roughly 1600 systems and portability really does matter when it comes to these numbers.
cheers
Michal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 04:30 AM
тАО04-08-2005 04:30 AM
Solution--8<---
Using perl as shipped with HP-UX
Application release September 2001, HP-UX 11.00 is the
first to ship with Perl. By the time it was perl-5.6.1 in
/opt/perl. The first occurrence is on CD 5012-7954 and can
be installed using
-->8---
And that's just talking about perl5.
perl4 is available on *all* hp-ux systems for a loooooong time:
d3:/u/usr/merijn 101 > uname -a
HP-UX d3 B.10.20 U 9000/800 2015358431 unlimited-user license
d3:/u/usr/merijn 102 > /usr/contrib/bin/perl -v
This is perl, version 4.0
$RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
Patch level: 36
Copyright (c) 1989, 1990, 1991, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 4.0 source kit.
d3:/u/usr/merijn 103 > /usr/contrib/bin/perl -l -e 'print time'
1112977707
d3:/u/usr/merijn 104 > ll /usr/contrib/bin/perl
2034 -r-xr-xr-x 1 bin bin 544768 Jun 10 1996 /usr/contrib/bin/perl
d3:/u/usr/merijn 105 >
So, unless you still maintain HP-UX 9.00 or any system older than 10.20, you can be safe in that using the bare
perl -e 'print time'
will work. Note that older perl's need a space between the -e and the 'print
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2005 04:33 AM
тАО04-08-2005 04:33 AM
Re: how to get timestamp
#!/usr/bin/sh
typeset -i EPOCH=$(epoch.sh)
echo "Epoch seconds = ${EPOCH}"
Search the Forums for an obscure script called "caljd.sh" to see where the strange looking function comes from.