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'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 serverfault.com Oct 22 '10 at 1:27

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

4 Answers 4

up vote 21 down vote accepted

You're looking for cron and shell scripts.

share|improve this answer
2  
@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/myscript.sh 
share|improve this answer
1  
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:

#!/bin/bash

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 filename.sh, 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

Your Answer

 
discard

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