On demand scheduled job runs when plugin is installed

I have written a plugin that defines an on demand scheduled job. It works exactly as intended, EXCEPT, it runs once when the plugin is first installed.

How would I prevent that?

Addendum: It actually runs every time the application starts up

Hi Robert,

How did you configure the scheduled job? If you are not already, consider using the job-config module in atlassian-plugin.xml. This allows you to have very fine control over how to configure the scheduled job including how it behaves in clusters and whether it can be run ad-hoc. Most importantly, you can define a cron-expression or an interval to control the schedule at which the job runs.

Have a look at this job-config module document for the full reference.

Yes, I did that. I set adhoc to true and repeat-interval to zero, because I only want it to run on demand.

    <job-config name="Attachment Report" key="attachmentReport">
        <job key="attachmentReport" perClusterJob="true" clusteredOnly="false"/>
        <schedule repeat-interval="0"/> 
        <managed editable="false" keepingHistory="true" canRunAdhoc="true" canDisable="true"/>

Hi again @RobertEgan!

Looking at the docs, it doesn’t explicitly mention any way to configure the schedule to never run. Even setting repeat-count to 0 means that it runs once.

Therefore, I can suggest that you try changing the schedule to a cron expression that is never executed. For example, a date in the past or far away in the future. Alternatively, if you can get away with it, try to use this expression 0 0 5 31 2 ? which runs on the 31st of Feb (so never!). Reference.