web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Batch job to be run only in day time.

(0) ShareShare
ReportReport
Posted on by 727

Hi Everyone,

How to run a batch job in day time only (any specific time).

Ex, i am going to run a batch job(TestBatch) with recurrence as no end date and hours count as 3.
The batch job(TestBatch) should run between the day time (ex: 10am to 6pm).

How can i achieve this in 2012 R2.


Thanks in advance,

Boobalan.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Batch job to be run only in day time.

    You can set up dependencies between batch tasks; i.e. "only run this task if the status of a previous task is Ended".  As such, you can knock up code which takes a start and end time as a parameter, and completes if the current time is within the given window; or errors if not.  Thus the outcome of that task will determine whether or not the next task in that batch runs.

    You can switch from having start and end time parameters to whatever level of complexity you need to support this requirement.

  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: Batch job to be run only in day time.

    At my previous company we have changed the SysRecurrence and Batch framework.

    With that, in the dialog dynamically built for the Recurrence setting we had an additional grid, where for each batch job we could define a Time fence (time between when the batch is allowed to run). We always initialized the grid with 0-24 all days, but you could alter the setting.

    The trick was to change the select statements if I remember correctly in Batch serverGetOneTask() and its' counterpart, and have an extra join in with the time fence table to exclude records in Waiting status based on the current server time, so they would only start once their execution time (and day) came.

  • Suggested answer
    PA-22040759-0 Profile Picture
    6,194 on at
    RE: Batch job to be run only in day time.

    Here is a real MacGywer suggestion...

    Duplicate the batch job into four jobs. One running at 10am, one at 1pm, one at 4pm and one at 7pm (I couldn't get the math with 3 hours between runs match with 6pm). And setup each job to run only once a day.

  • Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: Batch job to be run only in day time.

    I thought you said you already knew it. ;-)

    It seems that my answer isn't correct - I thought you can assign groups to server schedule, but it seems to be set up for the whole batch server regardless of schedule.

    You'll have to look for another solution. I would consider either implementing the logic described above (which I though it's already there), or extending the recurrence logic. If it's just an one-off requirement, a quick and dirty workaround would be checking current time directly inside your batch task.

  • Boobalan Profile Picture
    727 on at
    RE: Batch job to be run only in day time.

    I need some more clarification from your response,

    "Create two batch schedules: one for day and one for night. Then make sure that your batch group is included in the day schedule only".

    How can we assign a batch group for a specific batch schedule in server configuration.

    Ex: I have created two batch schedules as "Day" and "Night". Could you please elaborate how to assign a batch group for the batch schedule "Day" alone.

  • Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: Batch job to be run only in day time.

    What's the problem with this standard solution so they're willing to invest time to looking for something else, instead of just using it?

    By the way, you would have saved me some time if you mentioned that you already knew this solution.

  • Boobalan Profile Picture
    727 on at
    RE: Batch job to be run only in day time.

    Thanks for your response martin,

    We have already suggested this option to client but they are asking that, is there any other options available to achieve this in one AOS.

    Please advice.

  • Verified answer
    Martin Dráb Profile Picture
    236,192 Most Valuable Professional on at
    RE: Batch job to be run only in day time.

    Create a batch group for your day jobs.

    Then go to System administration > Setup > System > Server configuration and select a batch server. Create two batch schedules: one for day and one for night. Then make sure that your batch group is included in the day schedule only. Repeat if for additional batch servers if needed.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans