Run a timer task on a specific day (1st of every month) using Spring

dvrnaidu

We have a requirement of running a job on 1st of every month (time: 00:00:00 AM) exactly.
We are using Spring framework's ScheduledTimerTask to schedule jobs using delay and period properties. This class doesn't support running a job on specific date.

Can somebody suggest, how we can solve that problem using Spring and Java technology?

rgrebski

If you don't have to run this job on a single node in a cluster you can use Spring Task, see: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/scheduling.html

@Scheduled(cron="0 0 0 1 1/1 *")
public void doSomething() {
    // something that should execute on 1st day every month @ 00:00
}

For generating cron expressions try cronmaker.com

Please be aware that if you use this code in a cluster it will run on all nodes.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to schedule a task to run every weekday except on the 1st day of the month

How to schedule task which will execute every 1st day of month and update a value in Firebase realtime database

How do I run a script for 1st working day of every month in cron?

How to make it to select from 1st day every month

Snowflake task to run the job every 2nd day of month (working day)

How to run certain task every day at a particular time using ScheduledExecutorService?

Ruby: number of times a specific day of the month (eg. 1st of each month) occurs between two dates

systemd timer every X hours on a specific day

Pandas: convert date in month to the 1st day of next month

sql return 1st day of each month in table

Day of Week in Month (numeric). The example is for the 1st Wednesday in April

Run code every day at a specific time - AlarmManager

Is there an easy way to create a vector following the pattern: 1st day of the month, last day of the month, 1st day of the month etc.?

How to run Celery Periodic task at every end of the month

Run Recurrence trigger in Azure Logic App on the Last day of Every Month

Run Sql Job in The first day of every shamsi month (persian date)

How to get every single day of the current month in a specific format

How to get the date of a specific day in every month and year?

How to plot a graph for specific day of every month for whole Year MATLAB

How can I schedule a laravel task on a specific day of the month?

How do I select between 1st day of the current month and the 1st day of the following month (from current month) in postgres

Run Cron Job Every 15 Minutes in specific time and every day

I want to implement a spring cron scheduler that should run for the 1st time when the application is started and run every 1 hour from the next time

Running a specific code once at 1st run Android

jQuery datepicker will not allow selecting dates when month has 31 days and select 1st day of month

Golang Revel Job spec every 1st monday on every month

Scheduler for a task to run at particular hour of the day for every N days

SQL/VBA: How to group by a fiscal year starting from a day other than 1st day of month

Date Scalar Function to display 1st day or last day of the Month