Gopi
Gopi

Reputation: 105

Poll for every 45 minutes using cron

I need to poll after deployment immediately i.e 0 seconds and then for every 45 mins using cron

Should poll as follows:: 00:00, 00:45, 1:30,2:15,3:00 and so on

Upvotes: 1

Views: 2566

Answers (7)

Buddhi
Buddhi

Reputation: 2324

run every 10 seconds

0/10 * * * * ?

run every 45 minutes

* 0/45 * * * ?

Upvotes: 1

satya sandeep
satya sandeep

Reputation: 7

Instead of using the Cron jobs just go with fixed frequency scheduler simply. set the value as follows:

frequency: 45 start delay as :0

Time unit as:minutes

Upvotes: -1

dlb
dlb

Reputation: 357

Simply use the fixed frequency scheduler construct as stated by @Mooz and then get the current time, check if it is a Sunday and do not process if it is. A cron expression is not really directly intended to handle all of the constraints of running immediately, a frequency relative to starting time rather than a clock schedule, and a day scheduling even with Mule's extensions to cron. Other solutions would be to use two controllers, but this would seem cleaner to me.

Upvotes: 0

Harish Kumar
Harish Kumar

Reputation: 11

Cron expression (for every 45 mins): 0 0/45 * 1/1 * ? *

If you want to run every 45 mins(00:15,01:00 like this) use quartz. if you used poll operation it will not run every 45 mins, it will run every 45 mins when the project or flow deployed.

Upvotes: 0

Möoz
Möoz

Reputation: 863

Why do you have to use cron?

Your best bet in this case is to not use cron, rather use Mule's in-built fixed-frequency scheduler:

Screen capture showing the in-built polling strategy within Mule

Note how the the default delay is "0" which means that it will run immediately upon deployment, then will run every 45 minutes after.

Here is the configuration-xml:

...
<flow name="polling-frequency-example-flow"
    processingStrategy="synchronous">
    <poll doc:name="poll-every-forty-five-mins">
        <fixed-frequency-scheduler frequency="45" timeUnit="MINUTES"/>
    </poll>
    <!-- Do Something -->
</flow>
...

Upvotes: 2

Senthil c
Senthil c

Reputation: 341

  1. CRON expression to poll every 45 minutes, this will solve ur first problem.

    0 0/45 * 1/1 * ? *

  2. Running once immediately after the deployment can't be handled with "Poll" as far as I know. As a workaround, in addition to the Poll component above, create another flow with "QUARTZ Inbound Endpoint" and it has a repeatCount attribute which you can set it to "Zero"(this will run exactly once and won't repeat itself).

Upvotes: 0

Christian Pekeler
Christian Pekeler

Reputation: 1070

I don't know how to poll in Mule, but I can help you with your cron schedule.

Cron doesn't support every-45-minutes. You'll have to break it into three cronjobs:

0,45 0-23/3 * * *

30 1-23/3 * * *

15 2-23/3 * * *

Upvotes: 1

Related Questions