gocron icon indicating copy to clipboard operation
gocron copied to clipboard

Cron job exited after undefined amount of time

Open LeeU1911 opened this issue 8 years ago • 11 comments

Hey there,

Thanks for your great work!

I'd like to ask whether anyone runs into the same problem. I built a cron job that checks my gmail inbox every 10 seconds using Gmail API. The code runs fine but it quits running after a while.

By monitoring, I can see sometimes it quits after 3 hours, 8 hours or sometimes just around 15 20 minutes. I monitored the memory of the process but it looks like there is no memory leak issue since it take stably around 12MB when running for 1 minute.

Please comment if you ran into this problem or you have some clue about it.

Thank you, Vu

LeeU1911 avatar Apr 25 '16 10:04 LeeU1911

It may have to do with the following: https://github.com/jasonlvhit/gocron/blob/master/gocron.go#L38

alexanderbez avatar Feb 27 '17 15:02 alexanderbez

@jasonlvhit if you have a slice of a predefined size and simply don't want to append, when an overflow happens perhaps you can just flush and wrap back to the beginning? I'd be happy to help contribute.

alexanderbez avatar Feb 27 '17 15:02 alexanderbez

Thanks @alexanderbez but I don't get it yet. Isn't that constant the number of jobs? I only have one job.

LeeU1911 avatar Mar 01 '17 07:03 LeeU1911

Ahhh good catch @LeeU1911, I'll keep poking around. It could something on the system level killing it like oom.

alexanderbez avatar Mar 01 '17 15:03 alexanderbez

I am seeing this same issue. Job runs for sometimes one hour, sometimes four hours, then stops. No errors, app doesn't restart, but job just seems to stop running.

@preslavrachev @Streppel

JohnRoesler avatar Nov 06 '19 00:11 JohnRoesler

@JohnRoesler strange... I have a job running for weeks with no problem. I'll investigate

Streppel avatar Nov 06 '19 00:11 Streppel

I've been debugging on my end as well. It's running in docker. Tried increasing mem/cpu, still seeing it stop.

JohnRoesler avatar Nov 06 '19 01:11 JohnRoesler

It's not that the job is actually stopping my case. There are no errors, it just takes long breaks on job that's scheduled to run every 5 minutes.

Here is a screen shot of logs over a 12 hour period: image

Pretty sure it's not a resource issue as the docker container running the cron as an excessive amount of mem/cpu and usage is about 2% of resources.

Update - Nothing wrong with gocron! 🎉 It was a bug in my task that was causing the program to sleep for long periods of time. Sorry for the false alert.

JohnRoesler avatar Nov 06 '19 16:11 JohnRoesler

Hi, currently I have this issue..

I have a simple job to run every 5s. But the job seems suddenly stop after a random amount of time

I run the service using systemd. With this configuration:

Description=Devops Redis Agent
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/devops-redis-agent
User=devops-agent
Group=devops-agent

[Install]
WantedBy=multi-user.target

for now, I add auto restart every hour in the systemd configuration. PS, the CPU and memory load seems OK

truztee avatar Apr 01 '21 03:04 truztee

@truztee this repo is no longer maintained sadly. Come checkout our fork that is very well maintained and updated! https://github.com/go-co-op/gocron

JohnRoesler avatar Apr 01 '21 03:04 JohnRoesler

@truztee this repo is no longer maintained sadly. Come checkout our fork that is very well maintained and updated! https://github.com/go-co-op/gocron

ic... thank you for the information

truztee avatar Apr 01 '21 03:04 truztee