Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cron "15 1 * * *" triggers twice a day at 0100 and 0115 #219

Open
HeroXXiv opened this issue Feb 9, 2023 · 9 comments
Open

cron "15 1 * * *" triggers twice a day at 0100 and 0115 #219

HeroXXiv opened this issue Feb 9, 2023 · 9 comments

Comments

@HeroXXiv
Copy link

HeroXXiv commented Feb 9, 2023

i did a test on cron="15 13 * * *", now="1675915800" or "Thu Feb 09 2023 12:10:00 GMT+0800"

function
wait_for_cron '15 13 * * *' 1675915800 0
returns 3000, which is 50mins
65mins is expected.

issue occurs on both v0.11.0 and master.

@HeroXXiv
Copy link
Author

HeroXXiv commented Feb 9, 2023

incase log is helpful

bash-4.4# set -x
bash-4.4# wait_for_cron "15 13 * * *" 1675915800 0
+ wait_for_cron '15 13 * * *' 1675915800 0
+ local 'cron=15 13 * * *'
+ local compare=1675915800
+ local last_run=0
+ local comparesec=1675915800
+ local compareDiff=1675915800
+ '[' 1675915800 -lt 60 ']'
++ getepochas 1675915800 +%-S
++ local input=1675915800
++ local format=+%-S
+++ uname -s
+++ tr '[A-Z]' '[a-z]'
++ local os=linux
++ case "$os" in
++ date --date=@1675915800 +%-S
+ local current_seconds=0
+ '[' 0 -ne 0 ']'
++ echo -n '15 13 * * *'
++ awk '{print $1}'
+ local cron_minute=15
++ echo -n '15 13 * * *'
++ awk '{print $2}'
+ local cron_hour=13
++ ++ awk '{print $3}'
echo -n '15 13 * * *'
+ local 'cron_dom=*'
++ awk '{print $4}'
++ echo -n '15 13 * * *'
+ local 'cron_month=*'
++ ++ awk echo -n '{print $5}'
'15 13 * * *'
+ local 'cron_dow=*'
+ local success=1
++ getepochas 1675915800 +%-M
++ local input=1675915800
++ local format=+%-M
+++ uname -s
+++ tr '[A-Z]' '[a-z]'
++ local os=linux
++ case "$os" in
++ date --date=@1675915800 +%-M
+ local next_minute=10
++ getepochas 1675915800 +%-H
++ local input=1675915800
++ local format=+%-H
+++ uname -s
+++ tr '[A-Z]' '[a-z]'
++ local os=linux
++ case "$os" in
++ date --date=@1675915800 +%-H
+ local next_hour=12
++ getepochas 1675915800 +%-d
++ local input=1675915800
++ local format=+%-d
+++ tr '[A-Z]' '[a-z]'
+++ uname -s
++ local os=linux
++ case "$os" in
++ date --date=@1675915800 +%-d
+ local next_dom=9
++ getepochas 1675915800 +%-m
++ local input=1675915800
++ local format=+%-m
+++ tr '[A-Z]' '[a-z]'
+++ uname -s
++ local os=linux
++ case "$os" in
++ date --date=@1675915800 +%-m
+ local next_month=2
++ getepochas 1675915800 +%-u
++ local input=1675915800
++ local format=+%-u
+++ tr '[A-Z]' '[a-z]'
+++ uname -s
++ local os=linux
++ case "$os" in
++ date --date=@1675915800 +%-u
+ local next_dow=4
++ getepochas 1675915800 +%-Y
++ local input=1675915800
++ local format=+%-Y
+++ tr '[A-Z]' '[a-z]'
+++ uname -s
++ local os=linux
++ case "$os" in
++ date --date=@1675915800 +%-Y
+ local next_year=2023
+ next_dow=4
+ local cron_next=
+ '[' 1 '!=' 0 ']'
++ next_cron_expression 15 59 10
++ local crex=15
++ local max=59
++ local num=10
++ local allvalid=
++ local tmpvalid=
++ local parts=15
++ parts=15
++ for i in $parts
++ '[' 15 = '#' -o 15 = 10 ']'
++ partstep=15
++ partnum=15
++ tmpvalid=
++ local start=
++ local end=
++ '[' 15 = '#' ']'
++ start=15
++ end=15
+++ seq 15 15
++ tmpvalid=15
++ '[' 15 '!=' 15 ']'
++ allvalid=' 15'
+++ tr '\n' ' '
+++ echo 15
+++ tr ' ' '\n'
+++ sort -n -u
++ allvalid='15 '
++ for i in $allvalid
++ '[' 15 -ge 10 ']'
++ echo 15
++ return 0
+ cron_next=15
+ '[' 15 '!=' 10 ']'
+ '[' 10 -gt 15 ']'
+ next_minute=15
++ next_cron_expression 13 23 12
++ local crex=13
++ local max=23
++ local num=12
++ local allvalid=
++ local tmpvalid=
++ local parts=13
++ parts=13
++ for i in $parts
++ '[' 13 = '#' -o 13 = 12 ']'
++ partstep=13
++ partnum=13
++ tmpvalid=
++ local start=
++ local end=
++ '[' 13 = '#' ']'
++ start=13
++ end=13
+++ seq 13 13
++ tmpvalid=13
++ '[' 13 '!=' 13 ']'
++ allvalid=' 13'
+++ sort -n -u
+++ tr '\n' ' '
+++ tr ' ' '\n'
+++ echo 13
++ allvalid='13 '
++ for i in $allvalid
++ '[' 13 -ge 12 ']'
++ echo 13
++ return 0
+ cron_next=13
+ '[' 13 '!=' 12 ']'
+ '[' 12 -gt 13 ']'
+ next_hour=13
+ next_minute=0
++ next_cron_expression '*' 6 4
++ local 'crex=*'
++ local max=6
++ local num=4
++ local allvalid=
++ local tmpvalid=
++ local 'parts=*'
++ parts='#'
++ for i in $parts
++ '[' '#' = '#' -o '#' = 4 ']'
++ echo 4
++ return 0
+ cron_next=4
+ '[' 4 '!=' 4 ']'
++ max_day_in_month 2 2023
++ local month=2
++ local year=2
++ case $month in
++ local div4=2
++ local div100=2
++ local div400=2
++ local days=28
++ '[' 2 = 0 -a 2 '!=' 0 ']'
++ '[' 2 = 0 ']'
++ echo 28
+ maxDom=28
++ next_cron_expression '*' 30 9
++ local 'crex=*'
++ local max=30
++ local num=9
++ local allvalid=
++ local tmpvalid=
++ local 'parts=*'
++ parts='#'
++ for i in $parts
++ '[' '#' = '#' -o '#' = 9 ']'
++ echo 9
++ return 0
+ cron_next=9
+ '[' 9 '!=' 9 ']'
+ '[' 9 -gt 9 -o 9 -gt 28 ']'
+ next_dom=9
++ next_cron_expression '*' 12 2
++ local 'crex=*'
++ local max=12
++ local num=2
++ local allvalid=
++ local tmpvalid=
++ local 'parts=*'
++ parts='#'
++ for i in $parts
++ '[' '#' = '#' -o '#' = 2 ']'
++ echo 2
++ return 0
+ cron_next=2
+ '[' 2 '!=' 2 ']'
+ success=0
+ '[' 0 '!=' 0 ']'
++ getdateas 2023-2-9T13:0:00 +%s
++ local input=2023-2-9T13:0:00
++ local outformat=+%s
+++ tr '[A-Z]' '[a-z]'
+++ uname -s
++ local os=linux
++ case "$os" in
++ date --date=2023-2-9T13:0:00 +%s
+ local future=1675918800
+ local futurediff=3000
+ echo 3000
3000

@deitch
Copy link
Collaborator

deitch commented Feb 16, 2023

Something is broken about the cron calculation, specifically in that scenario. Those cron calculations in shell have been enormously painful since the very beginning.

@HeroXXiv
Copy link
Author

yeah, it was very surprisingly for me to see the whole cron stuff implemented by shell scripts.
i turned to DB_DUMP_BEGIN and DB_DUMP_FREQ settings, which are enough for me.

@deitch
Copy link
Collaborator

deitch commented Feb 27, 2023

Haha, try maintaining it! 😆

I have an implementation in go, it is pretty close to ready. Hoping to switch soon.

@pinkfloydFR
Copy link

Oh searching github because i have the same problem !

Thanks, will turn DB_DUMP_BEGIN and DB_DUMP_FREQ settings too !

@topsnet-holgerd
Copy link

Tried several routines (environment variables: CRON_SCHEDULE, DB_DUMP_CRON; config file), to get build in scheduler working, but none gives success, no output file!
We managed the task by scheduling via server cron with docker -run the database-backup container and the schedule once option.

@deitch
Copy link
Collaborator

deitch commented Jul 12, 2024

Highly recommend the go-based on 1.0.0-rc* (take the latest) over the shell based. The shell based one is not being supported any more. The only thing holding back from making the 1.0.0 GA is some of the config file reading via openapi3.

@topsnet-holgerd
Copy link

topsnet-holgerd commented Jul 15, 2024 via email

@deitch
Copy link
Collaborator

deitch commented Jul 17, 2024

@topsnet-holgerd if you are having specific dump or restore issues, please open separate issues for each one.

Based on what you are saying, dump works on master, which means that whatever it was in rc4 has since been fixed. If you can reproduce it, please open a new issue describing exactly how to recreate it.

For the restore, that looks like a real issue. Please open a new one, describe exactly how to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants