The rndc stats commands created /var/named/chroot/var/named/data/named_stats.txt file under RHEL 5.x or CentOS 5.x BIND 9 server. However, date is not is correct format. The date is in the following format:
grep 'Dump' /var/named/chroot/var/named/data/named_stats.txt
outputs:
+++ Statistics Dump +++ (1263408025)
--- Statistics Dump --- (1263408025)
+++ Statistics Dump +++ (1263408071)
--- Statistics Dump --- (1263408071)
+++ Statistics Dump +++ (1268304218)
--- Statistics Dump --- (1268304218)
+++ Statistics Dump +++ (1268304248)
--- Statistics Dump --- (1268304248)
How do I convert date (e.g., 1263408025) in a human readable format?
The number 1263408025 is seconds since 1970-01-01 and can be converted to a human readable format using the following simple date command:
$ date -d '1970-01-01 1263408025 sec'
Sample outputs:
Wed Jan 13 18:40:25 CST 2010
Your named stats was dumped on Jan/13/2010 at 18:40:25 local time.
More About UNIX Time
Unix time, or POSIX time, is a system for describing points in time, defined as the number of seconds elapsed since midnight proleptic Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds. See wikipedia article for more information or refer to man page:
$ man date
OR
$ info coreutils date
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -



{ 5 comments… read them below or add one }
Also possible in Perl :
perl -e ‘print(scalar(localtime(1263408025)));’
date -d ’1970-01-01 1263408025 sec’
is the same as
date -d @1263408025
general Unix Timestamp conversion:
A) in bulk, in Excel:
Step 1: Put the timestamp in cell a1.
Step 2: In cell a2, enter “=a1/86400+25569″. Don’t enter the double quotes.
Step 3: Apply a new format to this cell by right-clicking on the mouse and choosing “Format cells” -> “Numbers” -> “Custom”.
Step 4: In the “Type” field, enter “dd:mmm:yyyy hh:mm”.
You can build a timezone adjustment into the formula. To generate Eastern Daylight time, which is a 4 hour offset, use the formula
“=(a1-4*3600)/86400+25569″
Using Excel is the most convenient method if you have a number of timestamps to interpret, especially if you can easily paste them into a spreadsheet and apply the formula to them all at once.
B) in awk, using strftime
for example, to make squid logs more readable:
awk ‘{print strftime(“%y%m%d %H:%M:%S “,$1)” “substr($0,17,999)}’ squidlog > nicer
This format makes it easier to extract stats for a given day, or hour.
Excelente maestro.
Y sencillito…
… y sin ser argentino.
You can also do something like:
#!/bin/bash while read line; do nix=`echo $line | awk '{print substr($5,2,10)}'` see=`date -d '1970-01-01 '$nix' sec'` echo "${line%(*}($see)" >> toto2 done < totoTo have the log file with the readable date.