breejs / bree

Bree is a Node.js and JavaScript job task scheduler with worker threads, cron, Date, and human syntax. Built for @ladjs, @forwardemail, @spamscanner, @cabinjs.
https://jobscheduler.net
MIT License
2.96k stars 80 forks source link

cron job starts after timeout not after definition #223

Open tripower opened 12 months ago

tripower commented 12 months ago

Hello

my cron job definition is '0 35 17 *' so, it should run once a day at 17:35

to prevent maybe an other bug (because job starts at 17:34:58 and runs so twice) so I tried the attribute timeout '30sec' but with that, the job starts after startup of the program and not at the defined time with defined timeout

17:35:30

any ideas? thx

greetings Klaus

tripower commented 12 months ago

update 25.07.2023:

results: at PC1 with definition: "0 35 17 *" timeout: 30sec

START: 25.7.2023, 17:34:58 START: 25.7.2023, 17:35:01

at PC2 with definition "0 35 17 *"

START: 25.7.2023, 17:49:43 START: 25.7.2023, 17:50:00

update 26.07.2023: it seems to work with my sleep function inside the task but this can only be a hack and not a solution!

update 28.07.2023: START: 25.7.2023, 17:34:58 START: 25.7.2023, 17:35:01 START: 26.7.2023, 17:35:00 START: 27.7.2023, 17:34:58 START: 28.7.2023, 17:34:58

works with hack but why start the job before 17:35???

tripower commented 11 months ago

my workaround

attribute at workerdata to set value for seconds and at the beginning of a cron task job https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait