Cron Job Scheduling -- 8.0.1 Beta 3 AMD 64

Status
Not open for further replies.

TravisT

Patron
Joined
May 29, 2011
Messages
297
I'm not sure if this is a bug or just my lack of understanding.

I'm trying to schedule a cron job to scrub my zpool 2x a month, once on the 1st and once on the 15th of each month. It doesn't seem that this can be done from the GUI. I've tried selecting the hour and minute that I want the job to start, along with the dates of the month. It says that a day of the week is a required field. I tried selecting all days, but then scrub appears to run every day.

Am I missing something or is there an issue with this section of the GUI?
 

iustinig

Dabbler
Joined
Jun 26, 2011
Messages
12
Just a thought... This could happen if you created 2 cron jobs both using the slider for picking the day. If you picked with the slider 1 and then again 15 then what are you seeing is normal behavior. The 1 means every day while 15 means every 15th day (as in 15 and 30).

Another way to check this is from the command line. On a ssh session or from the shell (option 9) type cat /etc/crontab. The last entry should be your added cron job. You can google crontab and you will find how to interpret the numbers in the file. As a quick reference... the numbers are split by tabs and they mean as follows
minute;hour;day;month;day of the week; user; command.
Anything with a star means all the units for that section - a star in the 3 position means everyday;

If my assumption is correct then your last 2 lines will have a */1 and a */15.

Hope it helps
 

TravisT

Patron
Joined
May 29, 2011
Messages
297
Here's what I have listed on my cron output:

Code:
00      10      01,15   1,2,3,4,5,6,7,8,9,10,11,12      1,2,3,4,5,6,7   root    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin zpool scrub cargo >/dev/null 2>&1


Does this look correct? I haven't been able to verify if this is working or not yet...
 

iustinig

Dabbler
Joined
Jun 26, 2011
Messages
12
It looks correct. It should run as you want.
Now I don;t want to discourage you in any way but my pools came dirty a couple of times and for what seemed to be random reasons. I had a couple of installs of Freenas all giving me corrupted data on the pools. One day i just said enough. I took the stupid flash card out and put a hard disk instead, installed ubuntu server with zfs-fuse which imported the freenas pool with no problems. I rebuild the pool however just to have a nice clean setup and i had no issues so far. Performance-wise, maybe I lost 5-7MB/s in transfer rate but i have a more reliable system now. It does get a bit more complicated but if you google stuff you can easily share files with samba and create cron jobs that will actually run when you want them to.
 

TravisT

Patron
Joined
May 29, 2011
Messages
297
I haven't had any issues with corrupted pools with freenas and hopefully that won't change. The main reason I want to do weekly scrubs is to stay in line with the zfs best practices. I ran osol using zfs for a while and never ran a scrub until I had a drive come unplugged. When I did, it took over a week to resolved and another to scrub. That was one of the reasons I switched over to freenas.
 

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
Here's what I have listed on my cron output:

Code:
00      10      01,15   1,2,3,4,5,6,7,8,9,10,11,12      1,2,3,4,5,6,7   root    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin zpool scrub cargo >/dev/null 2>&1


Does this look correct? I haven't been able to verify if this is working or not yet...

Err don't do that.
Scrub is already set to be run periodically by default
 

pmow

Cadet
Joined
Oct 3, 2011
Messages
4
I thought scrubs were periodically done every 30 days? With consumer drives, the weekly schedule is recommended. In my particular application, I would really like to scrub more often, as the drives will be essentially idle most of the time and I just want to make sure data is intact as much as possible.

Is there any authoritative info on this? I can't find references to it in the documentation (8.0.1-RC2).
 

TravisT

Patron
Joined
May 29, 2011
Messages
297
You are correct that the drive scrubbing is done by default every 30 days. What I would like to see is a setting to change the interval of the hard coded scrub.

As for the reference, it's in the zfs guide published by solaris. I posted a link on these forums at one time I believe, because the same question came up. I'll try to dig it up later, or you can search my posts for the link.
 

pmow

Cadet
Joined
Oct 3, 2011
Messages
4
Ticket 286 says it is to be done for RC5. It also contains the best practices link you are talking about, TravisT.

In the meantime, the scrub script evaluates when the scrub was last run, or creation time of the pool if not. If a cron is run weekly to scrub a pool, the FreeNAS scrub script "800.scrub-zfs" will not scrub it again - this is especially useful for me, because I don't want it to scrub during the week. My only concern is not getting an email, a scrub report would be really useful.
 

pmow

Cadet
Joined
Oct 3, 2011
Messages
4
Here's what I have listed on my cron output:

Code:
00      10      01,15   1,2,3,4,5,6,7,8,9,10,11,12      1,2,3,4,5,6,7   root    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin zpool scrub cargo >/dev/null 2>&1


Does this look correct? I haven't been able to verify if this is working or not yet...

If you want it to only start at 10:00am, it looks great. For mine, I've enabled it for "every minute every hour", and the GUI generates */1 like so:
Code:
*/1     */1     */1     1,2,3,4,5,6,7,8,9,10,11,12      6       root    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin zpool scrub evidence >/dev/null 2>&1

Course, I am running every Saturday. Day of the week (the last column before the command) is 6 for Sat.
 

TravisT

Patron
Joined
May 29, 2011
Messages
297
As promised...

Run zpool scrub on a regular basis to identify data integrity problems. If you have consumer-quality drives, consider a weekly scrubbing schedule. If you have datacenter-quality drives, consider a monthly scrubbing schedule. You should also run a scrub prior to replacing devices or temporarily reducing a pool's redundancy to ensure that all devices are currently operational.

Link
 

tpusztai

Cadet
Joined
Sep 26, 2011
Messages
7
Here's what I have listed on my cron output:

Code:
00      10      01,15   1,2,3,4,5,6,7,8,9,10,11,12      1,2,3,4,5,6,7   root    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin zpool scrub cargo >/dev/null 2>&1


Does this look correct? I haven't been able to verify if this is working or not yet...


Actually, it isn't.

I had the same problem so I started reading and experimenting. For the cron daemon to work as you expect, you should specify a * instead of 1,2,3,4,5,6,7 in the day of week field; these are not the same. Unfortunately, you can't do it with the GUI.

Please read this section of the crontab man page:

"Note: The day of a command's execution can be specified by two fields -- day of month, and day of week. If both fields are restricted (i.e., aren't *), the command will be run when either field matches the current time. For example, "30 4 1,15 * 5" would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday."
 
Status
Not open for further replies.
Top