user358232
user358232

Reputation: 235

How do run a Unix command at a given time interval?

I want to run a Unix command (e.g. ls) at 5 minute intervals through a script.

Explanation:

I have a Unix script. In that script I have a command called "ls".

I want that "ls" command to run every 5 minutes from that script.

Upvotes: 3

Views: 11249

Answers (5)

carlpett
carlpett

Reputation: 12583

Use watch. The -n flag specifies interval in seconds, so

watch -n 300 ls

Upvotes: 13

silppuri
silppuri

Reputation: 337

You could use crontab for example. See http://en.wikipedia.org/wiki/Cron

for example i you want to run your script every five minutes via crontab it should look something like this:

#m  h dom mon dow user command
*/5 * *   *   *   root /path/to/script

Upvotes: 2

powerMicha
powerMicha

Reputation: 2773

Put your script into the Crontab via

crontab -e

More information about Cron you can find at wikipedia

Upvotes: 4

Bertrand Marron
Bertrand Marron

Reputation: 22210

while true; do
    ls
    sleep 300
done

?

Upvotes: 9

Related Questions