# ScheduledTask DateObject pattern to evaluate at same time everyday

I would like to create a ScheduledTask that evaluates at the same time everyday. Such as, evaluate function at 1:00 am everyday. The "Daily" timespec in ScheduledTask doesn't allow me to control the time when function evaluates everyday.

I have tried, as an example, to print something whenever the second of the day is 5.

SessionSubmit[ScheduledTask[Print["1"], DateObject[{_, _, _, _, _, 5}]]]


I get error

SessionSubmit::sched: \$Failed is not an association containing recognized scheduling time specification.


Either the pattern is wrong or I am approaching this in the wrong way?

• I think it is a valid form of time specification as said in the detailed information, so I suspect this is a bug of Mathematica... At least an improperly written documentation. I would dig a bit into the source code and try to figure something out... – Wjx Mar 31 '18 at 12:45
• It seems that the the processing of different type of time specification is by function TasksInterpretTimeSpec`. However, this feature is not included in all 11 valid definitions of it... So probably this is a feature that's not yet implemented or missed out. #facepalm# – Wjx Mar 31 '18 at 12:52
• Thank you! Thought I was going crazy. I’m getting frustrated that this stuff is all too common when using Mathematica. They have made strides over the years but so much more to polish. I will submit a bug report. – Ray Troy Mar 31 '18 at 17:42
• Yup, they are always adding new functionalities but always ignoring that there's still bugs to fix as well! – Wjx Apr 3 '18 at 2:11
• Whether that works or not -- I would suggest to not use Mathematica for such a task. It will only work if you manage to keep the Mathematica process which runs this alive for many days. That can be achieved but it is not really something that Mathematica was made for (and it eats a license permanently!). I think if you use more standard ways of the operating system you use to run scheduled tasks and start a new mathematica process for what you need to do once a day that probably will give you a more reliable and maintainable solution to your problem... – Albert Retey Apr 8 '18 at 10:52