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.

link|improve this question
feedback

migrated from serverfault.com Oct 22 '10 at 1:27

This question came from our site for system administrators and desktop support professionals.

4 Answers

up vote 21 down vote accepted

You're looking for cron and shell scripts.

link|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
feedback

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

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

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.

link|improve this answer
feedback

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

Look into incron

link|improve this answer
feedback

Your Answer

 
or
required, but never shown