UNIX Time and UNIX Timestamps

A recent comment on my story about converting UNIX timestamps to Oracle dates prompted me to do a little extra digging on UNIX time.

UNIX time is a standard system used not only in UNIX but in many other modern computer systems. Instead of being divided into years, months, hours, minutes, etc. UNIX time is simply a number which represents the number of seconds which have passed since midnight Coordinated Universal time (UTC, the same time zone as Greenwich Mean Time, sometimes referred to as Zulu time), January 1, 1970. This date is often referred to as the UNIX epoch.

Sound like a lot of seconds? It is. At the time of this writing it has been 1,145,404,660 since the UNIX epoch, but since people like to think of dates the old fashioned way, in years, months, days, hours, minutes and seconds the computer is almost always nice enough to convert the UNIX time into the familiar date and time format, and to your local time zone.

One of the strengths of UNIX time is that when it is recorded (a point in UNIX time is typically referred to as a UNIX timestamp) it is always relative to Greenwich Mean Time. That means UNIX timestamps can be easily converted to different time zones with no ambiguity.

For all the gruesome details on UNIX time, Wikipedia has a typically thorough article on the topic.

While there are several sites on the web to convert a UNIX timestamp to human readable format and vice-verse be careful. Many sites will do the conversion based on their time zone. 4WebHelp.net provides a great page for converting both ways.

In contrast to UNIX time, Oracle Databases record time in a more traditional year, month, day, hour, minute, second manner. In order to convert Oracle dates to a different time zone you need to know what time zone the date was originally recorded in. Only recently has Oracle introduced a time datatype with a time zone attribute.

unix, time, timestamp, time zone, date, oracle, database, solaris, linux

How Big Is That UNIX Directory?

Need to know how much space a directory and its contents are taking up on your UNIX system? Here’s what I use:

du -ks directory

The du command is used to summarize disk usage. Without any flags will show you the usage in blocks for every directory and subdirectory specified. Since the number of blocks varies by operating system we add the -k option to specify that we want the output in kilobytes. In many operating systems you could also use -h for a “human-readable” output with abbreviations like B for bytes, K for kilobytes, M for megabytes and so on.

The -s option lets us gather only the sum of the directory specified. Without the -s flag we would get output on every subdirectory as well as the specified directory.

$ du -k stuff
408560 stuff/patch
104 stuff/scripts
408688 stuff

One other thing that is useful for finding the biggest files and directories where there are a lot to sift through is to use a wildcard to size up multiple directories, then pipe the output of du to the sort command like this:

$ du -ks ./* | sort -n
0 ./sdtvolcheck727
8 ./mpztaWqc
8 ./speckeysd.lock
304 ./dtdbcache_:0
408688 ./stuff

With sort we use the -n option to order things by arithmetic value rather than alphabetic value (making 8 come before 304) so we see the largest things at the bottom.

Try it out. As always check the man pages for more info.

Easy Linux CommandsFor more tips like this check out my book Easy Linux Commands, only $19.95 from Rampant TechPress.

unix, solaris, linux, sysadmin, system administration, storage, storage administration

Getting Started with the Sun Fire T2000

SunFireT2000After receiving my try-and-buy Sun Fire T2000 over a week ago it’s finally up and running. While we have yet to hit it with much of a load, here are some thoughts on the out-of-box experience:

Before even powering up there are a couple interesting observations about the system. The first is the lack of power button, switch, or key. In fact there is only one button on the system and that is an indicator button which just flashes an LED on both the front and back of the system to make it easier to locate (a nice feature, by the way.) You’ll quickly find the hot-swappable dual power supply and fan compartment. The adventurous will find and the big button on top of the system which allows you to gain access to RAM and other non-hot-swappable components.

All of these compartments and components are accessible without the need for tools. The hard drives are on hot-swappable sleds which pop out the front of the box. The hard drives are small (2.5″ I believe) allowing room for 4 bays in the front and still affording enough space for ventilation. I was somewhat surprised to find laptop-style drives in a Sun server, but I guess I can’t come up with any reason not to.

After giving the hardware a good once-over it was time to get the T2000 up and running. I have to say Sun came up a little short on the out-of-box experience at this point. I’m comfortable with, even partial to the absence of on-board video on a server, and Sun has chosen to include serial via RJ-45 on the T2000. Sun was on the right track including two cables appropriately shielded for use with this port, but neglected to include an adapter to go to the 9 pin serial we all have on the back of our PCs.

After rummaging around for the proper adapter to hook the T2000 to an old laptop we plugged it in. The system is surprisingly (read obnoxiously) loud, but hey, it’s a server not a desktop. After a few minutes of the regular hardware diagnostics stuff the system came up to an sc> prompt.

This is where those who are not familiar with Sun’s newer hardware will come to a complete stop. The only documentation included with the system is the Sun Fire T2000 Server Getting Started Guide and that does little more than tell you what the different lights mean and where you can find more documentation online. If you get online and grab the Sun Fire T2000 Server Installation Guide this will walk you through dealing with the SC serial management port. In my opinion Sun should have included this one in hard copy with the system as well.

After a couple more steps things start to feel familiar and the rest of the setup is much like the Solaris 7, 8, and 9 installs I’m used to. With just a few extra steps here you can (and I’d recommend) configure the SC Network Management port which will allow you the same functionality as the SC Serial Management port without the need for the serial cable and adapter. You will need an extra network drop and IP address to use network management, but then you’ll be able to telnet to it for administrative functions. Of course in a production environment you’d want this behind a firewall or on a private subnet.

Other than that the system seems quick. Our next step is to get Oracle on the system and throw some queries at it. I’ll share more as soon as we get some results.

UPDATE: I have now had the chance to test drive some Oracle jobs on this system. Check out my findings here.

database, database administration, database administrator, dba, dbms, rdbms, solaris, sun, sunfire, sysadmin, system administration, systems administration, t2000, try and buy, unix, oracle

SunFire T2000 Try and Buy

SunFireT2000After being tipped of on the Sun try-and-buy program by Alan Baker, a coworker and cohort, I figured I’d throw my hat into the ring for a chance to test drive a SunFire T2000… and today it arrived.

Here’s what Sun has to say about their program:

Toss your toughest workloads at the multithreaded Sun Fire T2000 server with the Solaris 10 Operating System, and watch it crank up your database and Web application performance.

We’re so confident in the quality and performance of the world’s first eco-responsible server, we’re offering a free 60-day trial, risk-free. If you’re not totally impressed, just send it back at our expense and owe us nothing.

Chances are that you will be dazzled by your trial server and come back for more. The new Sun Fire T2000 server will likely become your multithreaded workload energy-saving powerhouse of choice.

When you apply for the Try and Buy program you get the choice of a four, six, or eight core 1GHz UltraSPARC T1 processor. I chose the eight, not just because bigger is better, but also because it is closest to our production Oracle servers in capacity and price.

So once we can find the time we’ll get 64-bit Oracle installed on there and run it through the paces. On deck are some join, function, lookup intensive datamart creation scripts which currently crush our production server every evening. This should be fun.

Also of interest is Sun’s claim of this server being “the world’s first eco-responsible server”. While I am unlikely to bring in a kilowatt meter to verify these claims, we are a very green university and hey, everyone wants to save a few bucks on electric.

UPDATE: I have now had the chance to test drive some Oracle jobs on this system. Check out my findings here.

oracle, database, database administration, database administrator, dba, dbms, rdbms, sun, solaris, systems administration, system administration, sysadmin, unix, t2000, try and buy, sunfire

UNIX Load Averages Explained

If you’ve spent much time working in a UNIX environment you’ve probably seen the load averages more than a few times.

load averages: 2.43, 2.96, 3.41

I have to admit that even in my sysadmin days I didn’t fully understand what these numbers were, but Zach did some digging a while ago to try to understand where these numbers are comming from.

In his blog entry from late last year, Zach sums it up quite nicely:

In short it is the average sum of the number of processes waiting in the run-queue plus the number currently executing over 1, 5, and 15 minute time periods.

The formula is a bit more complicated than that, but this serves well as a functional definition. Zach provides a bit more detail in his article and also points out Dr. Neil Gunther’s article on the topic which has as much depth on the topic as anyone could ever ask.

So what does this mean about your system?

Well, for a quick example let’s consider the output below. The load average of a system can typically be found by running top or uptime and users typically don’t need any special privileges for these commands.

load averages: 2.43, 2.96, 3.41

Here we see the one minute load average is 2.43, five minute is 2.96, and fifteen minute load average is 3.41.

Here are some conclusions we can draw from this.

  • On average, over the past one minute there have been 2.43 processes running or waiting for a resource
  • Overall the load is on a down-trend since the average number of processes running or waiting in the past minute (2.43) is lower than the average running or waiting over the past 5 minutes (2.96) and 15 minutes (3.41)
  • This system is busy, but we cannot conclude how busy solely from load averages.

It is important here to mention that the load average does not take into account the number of processes. Another critical detail is that processes could be waiting for any number of things including CPU, disk, or network.

So what we do know is that a system that has a load average significantly higher than the number of CPUs is probably pretty busy, or bogged down by some bottleneck. Conversely a system which has a load average significantly lower than the number of CPUs is probably doing just fine.

Easy Linux CommandsFor more tips like this check out my book Easy Linux Commands, only $19.95 from Rampant TechPress.

UNIX, systems administration, sysadmin, solaris, linux, load averages, system monitoring, sun, mac, osx