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


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

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 found under /etc folder.

  • 2
    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
  • 1
    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
  • Really not that hard to try it out yourself. – mimoralea Oct 2 '17 at 5:19

Use crontab.


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]
  • This won't work as the #do Stuff if it takes 3599 seconds to execute and then according to the requirement the script has to trigger the next second on wards and reset the clock to 0 but in this case it will pause at 3599th second and then proceed to sleep for next 3600seconds. There won't be an overlap but an unexpected gap between the iterations. Here I guess user is trying to execute a job every hour without cron. – mannoj Nov 10 '16 at 5:43

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)


With the cron utility


That's what cron is for.


Learn cron: http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy