Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com May 9 '10 at 22:33

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

9 Answers 9

cron.

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

Use crontab.

share|improve this answer

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
1  
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

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]
done
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)

:wq
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.