Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an indexer for sphinx, and i want it to run once every hour in linux. How would i do this?

share|improve this question

migrated from May 9 '10 at 22:33

This question came from our site for professional and enthusiast programmers.

Since everyone else is posting short answers, I thought I'd be a little more dscriptive...

cron is a daemon found on most *nix systems that runs scheduled commands at the specified intervals.

You add a script to the list by copying it to the folder of your choice:

  • cron.daily
  • cron.hourly
  • cron.monthly
  • cron.weekly

These folders are typically fount in /etc.

share|improve this answer
cron.* folders are very much distro specific. crontab is the universal way of having items run by cron at specified intervals. – MDMarra May 9 '10 at 22:51
True. I'm just giving an example. crontab gives you much more control anyway. – Nathan Osman May 9 '10 at 22:55


share|improve this answer
and use crontab to edit the crontab file ... see for a nice intro – Doug Harris May 10 '10 at 1:56

Use crontab.

share|improve this answer

Just to be different -

depending on your needs you could use the watch command.

  watch --interval=3600 command
share|improve this answer
Does this run the command every 1 hour; or does it run the command, wait 1h, and then run again? Note it makes a good difference if the command takes very long. (I ask because it wasn't clear from the man page.) – Malabarba Jul 24 '13 at 14:52

With the cron utility

share|improve this answer

That's what cron is for.

share|improve this answer

If you just need it once in a while, not permanently like you get with cron, and the watch solution isn't flexible enough, you can also use good old bash scripting:

while true; do
   # do stuff
   sleep $[60 * 60]
share|improve this answer

you'll edit the cron file by entering the command crontab -e

which drops you into a 'vi' editor (for current Linux and FreeBSD).

then enter the following: (type 'i' for insertion)

00 * * * * /path/to/sphinx_indexer.exe

then save and exit (press 'esc' then type the following)

share|improve this answer

You must log in to answer this question.