Reputation: 1782
I am trying to add a cron job that should run every day at 12 pm. I am facing a few issue and have a few doubts.
I was able to run it every minute but couldn't run it at a specific time.
How to know which timezone is expected and which timezone is set in the "nextcall" field
It doesnt run until I open console in the browser. How can it be done so that it runs at the server and no additional action is needed?
<record id="ir_cron_module_get_active_sr" model="ir.cron">
<field name="name">Get Active Srs</field>
<field name="user_id" ref="base.user_root" />
//<field name="interval_number">2</field>
//<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field name="nextcall" eval="(datetime.utcnow() + timedelta(days=0)).strftime('%Y-%m-%d 12:22:00')" />
<field name="doall" eval="True" />
<field name="model" eval="'sd.cron'" />
<field name="function" eval="'get_active_srs'" />
<field name="args" eval="'(None,)'" />
<field name="priority">1</field>
</record>
Upvotes: 1
Views: 3254
Reputation: 81
Maybe you are omitting this line:
<field name="active">True</field>
Functionally you can check it under Settings --> Automation --> Scheduled Actions
with the debut mode activated.
What I can see on your code is that this 2 lines aren't well commented (you wanted to comment them or it was a copy pasta mistake?)
//<field name="interval_number">2</field>
//<field name="interval_type">minutes</field>
Check if that's the right time you want to run the next test, it is in UCT time, you can check the UTC time in linux with timedatectl
on a terminal (in ubuntu at least)
<field name="nextcall" eval="(datetime.utcnow() + timedelta(days=0)).strftime('%Y-%m-%d 12:22:00')" />
I don't know in what context are you using this cron, but remember that the model must be the one that contains the function that you are calling. So, be sure that sd.cron
has the method get_active_srs
<field name="model" eval="'sd.cron'" />
At the end, if you are not passing any arguments you can omit this line
<field name="args" eval="'(None,)'" />
Upvotes: 1