All in the <head>

– Ponderings & code by Drew McLellan –

– Live from The Internets since 2003 –

About

Locate on OS X

13 July 2004

A lot of ‘nix based operating systems have a useful tool called locate. Locate is simply a command line tool that helps the user find files. It does this by maintaining an index of the file system that can be searched much more quickly than the file system itself.

On the various Debian and Fedora web servers that I use, I rather take locate for granted. If I need to find the PHP configuration file, for example, I do a quick

locate php.ini

and back comes a list of locations where a file called php.ini exists. Simple, elegant and above all transparent. Except on my mac, that is. Ever since taking delivery of my Powerboko I’ve been hitting a wall each time I tried to use locate. The above search for a php.ini would simply return a fairly unhelpful error about a missing database or something. I never took much notice because, almost by definition, I was doing something more important at the time. If I’m trying to find a file from a shell it’s because something important needs doing.

Well this week I snapped. This helpful page pointed out exactly how to build the database used for indexing – the database the error message was harping on about. Simply put:

sudo /usr/libexec/locate.updatedb

Now, this raises questions for me. Locate has always worked fine on my old iMac, and similarly on our G4 PowerMac at work. Both of these machines run 24/7. Could my lack of a locate database be symptomatic of basic system housekeeping failing to run? Should there be housekeeping tasks running to keep my Powerboko in check, and if so, is there an easy way to confirm what they’re up to?

I think I need me a sysadmin.

- Drew McLellan

Comments

  1. § pab: Yes… have a look at /etc/crontab.

    You’ll see the daily, weekly and monthly housekeeping is scheduled for the wee small hours. Wind it forward to a time when your machine’s likely to be powered up (or if you have Panther, set it to wake up in time).

    Alternatively, run the equivalent commands (sudo periodic weekly) when you remember.

    /usr/sbin/periodic just ends up calling the scripts in /etc/periodic/*/*. Put more housekeeping stuff in there.
  2. § Drew McLellan: Cheers pab. You’re an angel.

    I thought I’d checked for cron jobs – but I was using Cronnix. I guess this automatically excludes default system jobs. That’ll learn me to rely on fancy-pants graphical tools.
  3. § Lllama: Have a look at MacJanitor. Supposedly you can get it here but the site times out at the moment.

    It’s a GUI for firing off the jobs set to run in the wee hours, including updatedb.
  4. § Alex: I use MacJanitor too. do a search for it on version tracker. it only takes a couple of minutes to run.
  5. § Nathan Pitman: What’s a ‘Powerboko’? Sounds neat. ;)
  6. § Tim Uruski: You could also use Macaroni which performs a whole bunch of timely housekeeping.

Photographs

Work With Me

edgeofmyseat.com logo

At edgeofmyseat.com we build custom content management systems, ecommerce solutions and develop web apps.

Follow me

Recent Links

Affiliation

  • Web Standards Project
  • Britpack
  • 24 ways

I made

Perch - a really little cms

About Drew McLellan

Photo of Drew McLellan

Drew McLellan (@drewm) has been hacking on the web since around 1996 following an unfortunate incident with a margarine tub. Since then he’s spread himself between both front- and back-end development projects, and now is Director and Senior Web Developer at edgeofmyseat.com in Maidenhead, UK (GEO: 51.5217, -0.7177). Prior to this, Drew was a Web Developer for Yahoo!, and before that primarily worked as a technical lead within design and branding agencies for clients such as Nissan, Goodyear Dunlop, Siemens/Bosch, Cadburys, ICI Dulux and Virgin.net. Somewhere along the way, Drew managed to get himself embroiled with Dreamweaver and was made an early Macromedia Evangelist for that product. This lead to book deals, public appearances, fame, glory, and his eventual downfall.

Picking himself up again, Drew is now a strong advocate for best practises, and stood as Group Lead for The Web Standards Project 2006-08. He has had articles published by A List Apart, Adobe, and O’Reilly Media’s XML.com, mostly due to mistaken identity. Drew is a proponent of the lower-case semantic web, and is currently expending energies in the direction of the microformats movement, with particular interests in making parsers an off-the-shelf commodity and developing simple UI conventions. He writes here at all in the head and, with a little help from his friends, at 24 ways.