How can I configure a monthly cron task?

I've added this to crontab
Code:
0 2 1-7 * 2 /sbin/zpool scrub tank

According to the cron manual, this should mean that this task should execute every first Tuesday of the month at 2:00 AM
But for some reason it executes every day... What have I done wrong?
 
Did you add this to /etc/crontab? Or did you use crontab -e?

The latter is the preferred one, /etc/crontab mostly contains system stuff and really shouldn't be touched.

Alternatively, you can also have a look at periodic(8). Especially if you want to run things on a daily, weekly or monthly basis.
 
May be it is not what you actually need, but may be this will help you:
cron1.png
 
Yours is so pretty with it's drop shadow!

setevoy said:
May be it is not what you actually need, but may be this will help you:
cron1.png

Mines ascii() and can be put in crontab() as a comment:
Code:
*    *    *    *    *  command to be executed
┬    ┬    ┬    ┬    ┬
│    │    │    │    │
│    │    │    │    │
│    │    │    │    └───── day of week (0 - 6) (0 is Sunday, or use names)
│    │    │    └────────── month (1 - 12)
│    │    └─────────────── day of month (1 - 31)
│    └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)
 
As I understand the manual (see note), your command is executed from 1 to 7 of the month and every Tuesday.
If you want your command is runned precisely on every Tuesday, you can use at().
 
Actually crontab understand a much simpler language:

Code:
@monthly     /path/to/script #   Run once a month, meaning-> "0 0 1 * *".

my 2 cents :p
 
Back
Top