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'm using RSync with my buddy just for testing and general geekery, we want to somehow schedule the sync task to run every X time.

Using the terminal, we run the command and it works.

  1. What can we use to run a script every X time?

  2. How can we program something like a Windows .bat file for Linux?

Our operating system is Ubuntu.

share|improve this question

migrated from Oct 22 '10 at 1:27

This question came from our site for system and network administrators.

up vote 21 down vote accepted

You're looking for cron and shell scripts.

share|improve this answer
@Bobby: I wasn't giving Google as an answer. But thanks for playing. – Ignacio Vazquez-Abrams Oct 22 '10 at 18:13

following would run a script every 3 minutes if placed in your crontab

*/3 * * * * /home/sergio/ 
share|improve this answer
I have never used the slash notation. That is nice. +1 for you! – Buggabill Oct 22 '10 at 14:38

For part A, you'll want Cron. Tim Hoolihan has a good example of that in his answer.

For part B, you'll want a shell script. To make one, just make a textfile that starts with the following line:


And then follow that with commands like you were typing into the shell. (Advanced tip: the #! syntax works for any command-line program, not just bash.)

Once that's done, save it (it's recommended to use a .sh extension, but not at all neccessary), go to your shell and run chmod ugo+x, substituting the actual filename, of course. This will make it so your script can be executed.

Finally, just put the script in the crontab per Tim's answer.

Hope this helps.

share|improve this answer

In the context of rsyncing files, you can also make it happen as soon as there are new changes.

Look into incron

share|improve this answer
Just fyi, incron doesn't look like it's been updated out of alpha status since this answer. – John Moeller Jul 16 '15 at 21:33

You must log in to answer this question.