Linux “timer” command

I was setting up a new server to be monitored this week and found a new Munin script that I’d not seen before. It is http_loadtime. It loads a page on the server (http://localhost/) and times the duration of the load to be complete. On the server I was setting up it all went fine and started to graph right away.

Tux

I figured this would be a nice thing to see on the other web servers I manage so I added this new script to those servers as well…but that’s when I started to run into issues. The script wouldn’t run due to a missing “timer” command. The script does a “which timer” to find the location of the timer command so that it can call it from the full path…a very sensible thing to do. The problem was that the “which timer” command didn’t return anything. A search of the server showed the command was no where to be found. There are other timer type libraries, but not the actual timer command.

The funny thing is when I executed the timer command from the command line outside the script it worked fine and exactly as expected. So where is the damn timer command then? How does it work?

After lots of searching which resulted in far too many results with people wanting to change the clock on their server and nothing to do with what I was looking for. I found an interesting note somewhere (can’t find the link again sorry) that mentioned the timer command may be build into the shell.

That was the info I needed. I knew about some commands being build into the shell, but never actually knew what they were. Apparently in the default install of CentOS 5 the bash shell has “timer” built in. Armed with that info it was a simple matter of doing a yum install timer and I was good to go. Script worked perfectly fine as is.

PS: This is an odd issue but for those looking for the answer it’s super hard to find in the search engines. So please link back to this post if you find it helped you. Hopefully we can get this posts ranking high enough that it’ll show higher on Google to help the next person.