I have a UI where users select on which day of each month they want to receive an email. What happens if they select the 31st? How does Hangfire handle the days which have only 30 day or february?
Thank you!
In case anyone comes back to this - this limitation was lifted in Hangfire 1.7 when they migrated to Chronos for recurring CRON expression support.
According to this issue, Hangfire lacks the capability to schedule any job for the last day of the month.
Hangfire use NCrontab, that's not support for # or L
Your best bet (at the moment) is to:
Schedule multiple jobs manually (using calendar to figure out last day of the month or other methods to figure out days in a month)
Not use Hangfire (use something that is more capable in terms of cron type scheduling)
FluentScheduler does have support for LastDayOfTheMonth
Schedule(() => Console.WriteLine("This task will run at last day of every month."))
.ToRunEvery(1)
.Months()
.OnTheLastDay();
Related
I have jobs that need to be scheduled on the second to last Monday of a month. Is this possible with current functionality?
From what I've seen, it doesn't seem to be possible with standard cron expressions.
Currently I have the job running every week and a check inside the job to see if it is the correct week, but I'd rather not use this set up as it still registers the job as running and being successful.
Thanks!
I was able to answer my question. I made a small addition to the cron expressions file in the apscheduler module and added a class that allowed for [-1, -2, etc]. Then was able to use that as an index for a calendar from the calendar module to grab the week I wanted. So now it allows for expressions like '-2 thu'.
If someone wants more help with how I implemented this, let me know.
I have a recurring Hangfire job that runs daily. As part of the logic the job fetches entities created within the last 24 hours. It uses DateTime.Now in the logic. I realize that this is not a robust design in the case that the job fails and it is run several days later. Is there any way I can pass the current time as a parameter to a recurring job? Or do I need to rewrite the logic to be independent of the current time? I have tried RecurringJob.AddOrUpdate(() => FooAction.Execute(GetTime()), cronSchedule); but as expected that just always passses the time that the recurring job was created.
One idea would be to skip the recurring job and create a regular Hangfire job instead. The last thing the job should do is create a new job and pass the specified time as parameter. But I would prefer to use a recurring job if I can.
"You could have a recurring job run that is responsible for creating non-recurring jobs, and passing the current time into those."
From comment by #mason.
I'm new to Camunda and didn't find any tutorial or reference explaining how to achieve the following:
This is a workflow to monthly hour registry. So an employee should compile a "form" task to insert how many hours he has worked every day in the month and save it on a sheet for example. At the end of the month the account take the sheet with the hours and make a kind of report for each employee.
Is it possible to handle this kind of recursion (do a task once a day into the month) with camunda and any idea how to make it with a bpmn graph?
How do I run a job in Sql Server Agent in (SQL Server Management Studio) for 'x' number of days in a month?
eg: Every 1st.2nd and 3rd of every month
The problem is I am not sure of these days! The user will specify the 'x' number of days!
For instance, the user feels for the month of April he wants the job to be scheduled on 'x' days. Here x= 1st,2nd and 4th of April.
And for the month May he feels to schedule on 'x' days. Here x= 7th,8th and 10th!
Is it possible to schedule in such a way?
Is there any script to schedule this???
Make a schedule that's run on those three days. Assign this job to that schedule.
(To elaborate and make it perfectly clear).
Make three schedules (Rightclick Jobs, Manage Schedules).In new schedules choose - Recurring on monthly. One starts the 1st, one starts the 2nd, one starts the 3rd of every month (for example, or x times for whatever day of month you wish).
Name these schedules something that's easy for you to spot in a list.
On the job you wish to run on these days, properties on it, schedule, then pick the schedule(s) you want to assign to the given job.
That should be all.
If the schedule is user defined then I'd probably just schedule the job to run every day and have the first step be to check whether it should be running today and if not exit.
Check Howto Schedule a Job and follow the Instructions of cairnz.
I know how to run autosys job on certain day in a week but how can i run once in a month.. like if i have to run job1 on 2nd day of the month .. any help would be good for me.. thank you
You can specify a day of the month with an extended calendar with the condition MNTHD#nn, where nn is the nnth day of the month.
The extended calendar can be defined like
extended_calendar: second_of_month
condition: MNTHD#2
and you can include the calendar as the run_calendar attribute of your job like
insert_job: job1
run_calendar: second_of_month
Find more information here on the different conditions for an extended calendar.
Use a run calendar. Create a calendar with the days you want the job to run on and add that calendar to the job. The current version of Autosys, R11 allows you to use logic to create calendars. For example the first business day of the month.