Jump to content
  • Scheduling a job on the last day of every month


    vchiem
    • Features: JasperReports Server, Scheduler Version: v7 Product: JasperReports® Server

    Issue:

    How can the report schedule be set up so that it always runs on the last day of every month at a certain time such as 23:30 ?

     


     

    Solution:

    As the last day of each month varies by month it is a complex functionality that the scheduler currently does not support. The online Scheduled jobs user interface (UI) does not have the facility for the user to configure this option.  

    Usually the business reason for scheduling a report to run at the end of the last day of the month is to include the results for the current month. Hence a workaround is to schedule reports to run at 12:01 am on the first day of the next month. 

    There were a couple of enhancement requests raised (incident references JS-5370,JS-25055) for this feature but a target release has yet to be confirmed.

    Should the workaround above not be suitable for whatever reasons, it may be possible through customizations or non-standard approaches. The calendar trigger is stored as a cron expression in the table qrtz_cron_trigger and the Quartz documentation (see 'Related Articles' section for link) has a cron expression to fire the job on the last day of the month. 

    The example provided by Quartz is :
    
    Expression: "0 15 10 L * ?"    
    Meaning: Fire at 10:15am on the last day of every month

    Note: Since this is a non-standard approach, it has not been officially tested and is not a supported approach. Doing this requires the appropriate level of testing by the user to ensure it is an acceptable approach. 

     

    Related Articles:

    - JS-5370: Scheduler - Enable more complex recurrence

    - JS-25055: Option for Last day in a month

    - https://stackoverflow.com/questions/11880231/jasperserver-schedule-report-at-last-day-of-month

    - http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html

     


    User Feedback

    Recommended Comments

    How do I look up these cases? 

    - JS-5370: Scheduler - Enable more complex recurrence
    - JS-25055: Option for Last day in a month

    If regular members of the community don't know how to access them, they're not very good references.

     

    Link to comment
    Share on other sites

    1) Refer to https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm to set the correct cron expression for the last day of month report execution. for example:

    0 15 10 L * ? Fire at 10:15 AM on the last day of every month

    2) Create a Calendar Recurrence type job with any settings such as Every Month Every Day 0 hour and 0 minute from JRS scheduler web UI.

    3) After the job is created, find the job ID, such as 20318 and use it in the following SQL to update this job's cron expression to run it on the last day of the month.

    update qrtz_cron_triggers set cron_expression = '0 15 10 L * ?' where trigger_name = (select trigger_name from qrtz_triggers where job_name = 'job_20318')

    Link to comment
    Share on other sites



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...