The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
epoch time ali560045 Shell Programming and Scripting 3 06-02-2008 01:41 AM
script to convert epoch into human-readable snoman1 Shell Programming and Scripting 3 04-18-2008 12:59 PM
Epoch time 12yearold UNIX for Advanced & Expert Users 2 07-14-2006 12:11 PM
Epoch time 12yearold Shell Programming and Scripting 1 07-14-2006 08:57 AM
Convert from standard epoch time from a shell script? LordJezo Shell Programming and Scripting 4 09-18-2005 08:48 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-19-2005
Registered User
 

Join Date: Jul 2005
Posts: 30
Question how to convert epoch time to readible format?

Hi,
I would like to convert epoch time from the logs to readible fromat.
How do I do it within shell?

Thanks!
Reply With Quote
Forum Sponsor
  #2  
Old 12-19-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
what OS are you on?
Reply With Quote
  #3  
Old 12-19-2005
Registered User
 

Join Date: Jul 2005
Posts: 30
what OS are you on?

what's the command to do it?
Reply With Quote
  #4  
Old 12-19-2005
Registered User
 

Join Date: Jul 2005
Posts: 30
OS config

ok.
Here it is:
System Configuration: Sun Microsystems sun4u
Memory size: 512 Megabytes
Reply With Quote
  #5  
Old 12-19-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
Aim this module at your perl ie., #!/path/to/your/perl
Code:
#!/usr/bin/perl
# date from time_t seconds since the start of epoch  then.pl
$then = localtime($ARGV[0]); 
print("$then\n");
usage:
Code:
logdate=`then.pl <time since start of epoch>`
echo "$logdate"
Reply With Quote
  #6  
Old 12-19-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
Code:
#!/bin/ksh

# here's my current EPOCH time
currentEpoch=$(/usr/bin/truss /usr/bin/date 2>&1 | /usr/bin/awk '/^time/ {print $NF}')

# here we convert EPOCH back to human readable format
back2Human=$(echo "0t${currentEpoch}=Y" | /usr/bin/adb)

echo "date->[$(date)] currentEpoch->[${currentEpoch}] back2Human->[${back2Human}]"
Reply With Quote
  #7  
Old 12-19-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
cin2000, "uname -a" will tell you the os.

vger99, I like that procedure to to get the internal time. I'll never use it, mind you. But I like it anyway. Another way which requires root (or at least non-standard) permission: "echo time/D | adb -k" I used to like these adb tricks but since 64 bit kernels started to arrive they are not as much fun. On a 64 bit kernel, you may need: "echo time+4/D | adb -k"

Between the 32/64 bit confusion and the user permission problems, I have started using perl for this stuff: perl -e 'print time, "\n"'.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0