user559096
user559096

Reputation: 107

Doing a task at specific time frequently

I want to run a program at specific time in every day of every week. how can I do this ? my OS is ubuntu. thanks

Upvotes: 0

Views: 63

Answers (4)

Icarus
Icarus

Reputation: 63956

type crontab -e <enter> from the command line

And then add an entry with the following format:

*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

For example:

30   18   *  * *  rm /tmp/* 

Will execute rm /tmp/* every day at 6:30 PM

More examples here.

Upvotes: 0

lurker
lurker

Reputation: 171

This might be an easier read than the man page. Best of luck!

Upvotes: 1

Thomas
Thomas

Reputation: 364

That's called a crontab. With the command crontab -e you can add a task.

A line in the crontabfile looks like this:

*    *    *    *    *  command to be executed
┬    ┬    ┬    ┬    ┬
│    │    │    │    │
│    │    │    │    │
│    │    │    │    └───── day of week (0 - 7) (0 or 7 are Sunday, or use names)
│    │    │    └────────── month (1 - 12)
│    │    └─────────────── day of month (1 - 31)
│    └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)

See http://en.wikipedia.org/wiki/Cron

Upvotes: 3

Nemanja
Nemanja

Reputation: 1171

Use cron daemon, to access manual try:

man cron
man 5 crontab

Upvotes: 1

Related Questions