Run task every second week

troudee

Explorer
Joined
Mar 26, 2020
Messages
69
Happy New Year everybody! :smile:

I've come up with the following task schedule:

- SMART Short test: Every Sunday at 23:00:00
- SMART Long test: Every second monday at 23:00:00
- Scrub: Every second monday (one week after the SMART Long test) at 23:00:00

My problem lies in the "every second monday" -- how can I set that in the GUI? I've thought about restricting the days (like [1-7], [15-21], [29-31]), but that does not seem to work (after a 31-day month starting on Monday, it would run the task on 1st, 15th, 29th and 5th of the next month -- that's 7 days after the 29th).
 

Flashbin

Dabbler
Joined
Jan 29, 2020
Messages
17
I'm not sure that's possible with the TrueNAS GUI - and even with normal cronjobs it's quite complicated I imagine.

I have it set up like this:
1609589744927.png


This runs approximately every other week (depending on how long the month is, there can be a two week gap). As far as I can tell, this is the closest you can get.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
It looks from this reference: https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm

That you could so something like:
0 23 0 ? * 2#2,2#4

That should run at 23:00 on the second and fourth Monday of each month

Although you're going to need to consider how important it is to have it every 2 weeks, since some months have 5 mondays, which you could work around by doing it like this (which would mean sometimes that you get it two consecutive weeks):
0 23 0 ? * 2#1,2#3,2#5

EDIT: I do see you're not going to be able to do that in the GUI though, since the days of week part is limited to the checkboxes... a pity that there's no true custom option.
I don't know if you can get away with ticking only Monday and using */14 in the days...
 
Last edited:

Flashbin

Dabbler
Joined
Jan 29, 2020
Messages
17
I don't know if you can get away with ticking only Monday and using */14 in the days...
Ticking Monday AND using */14 in the days does not produce anything usable. However, only using */14 and not ticking anything else does produce a biweekly task, but again with the problem that it may run on the 29th and on the 1st of the next month...
 

Flashbin

Dabbler
Joined
Jan 29, 2020
Messages
17
hello
maybe (sure) that screen help
the explanation of threshold IS the "explanation"
cheers
Sadly, Threshold is only available for Scrub Tasks and not for SMART Tests or normal Cron Jobs. So this is not the solution.
 

Dan Tudora

Patron
Joined
Jul 6, 2017
Messages
276
hello
many users of that forum, thanks @joeschmuck use another setup/schema of SMART/SCRUB cron job
SMART short daily at what hour you want (your server is not soo busy) without saturday and sunday
SMART long weekly saturday at hours bla, bla, bla
SCRUB at 28 days threshold sunday at hours bla, bla, etc
is logic ??
 

troudee

Explorer
Joined
Mar 26, 2020
Messages
69
Oh my, I wouldn't have thought this would be that complicated! :-D

What would you say about that:
  • SMART Short test: Every 1st, 8th, 15th, 22th, 29th @ 23:00:00
    This gives a shorter interval inbetween months, 29 (30, 31), 1 or 29 (30), 1 or 29, 1 in leap Februaries, but since it is the short one, I think I can live with that.
  • SMART Long test: Every 2nd, 16th @ 23:00:00
    This gives a mostly longer interval inbetween months, 16, (16 days), 2 or 16, (15 days), 2 or 16, (14 days), 2 in leap Februaries or 16, (13 days), 2 in normal Februaries.
  • Scrub: Every 9th, 23th, at 23:00:00
    15--16 days in normal months, 14 days in leap Februaries, 13 days in normal Februaries
 

Flashbin

Dabbler
Joined
Jan 29, 2020
Messages
17
Sounds good to me. I don't think you can get it better than that without much more effort, and frankly, I don't think it's really worth the effort. Most important thing to me is that it runs at all, even if it runs a week late.
 

giuseppe30

Dabbler
Joined
Dec 20, 2020
Messages
36
for now this is my setup:
- SMART short: every 4th, 11th, 18th, 25th at 23:00;
- SMART long: every 15th at 23:00;
- SCRUB test: every 28th at 23:00;

But as these two last tests make many hours I would that the SMART long run at first Saturday of the mounth at 9:00 and SCRUB at the second Saturday of mounth at 9:00 (and SMART short every Wedsney of the week at 23:00).
So the test can be work on Saturday/Sunday when my office is out and nobody access on nas.
 
Last edited:

troudee

Explorer
Joined
Mar 26, 2020
Messages
69
for now this is my setup:
- SMART short: every 4th, 11th, 18th, 25th at 23:00;
- SMART long: every 15th at 23:00;
- SCRUB test: every 28th at 23:00;

But as these two last tests make many hours I would that the SMART long run at first Saturday of the mounth at 9:00 and SCRUB at the second Saturday of mounth at 9:00 (and SMART short every Wedsney of the week at 23:00).
So the test can be work on Saturday/Sunday when my office is out and nobody access on nas.
At least I have no idea how to accomplish that -- you can see that I myself gave up figuring out how to bind the execution to weekdays and just used the day-of-month numbers.
 
Top