I've been learning how to make Discord bots recently and have been experimenting with scheduled messages. Currently, I have 8 or so messages scheduled to send throughout the week. Some send at a certain time every single day, while some send at a specific time only on the weekends, etc.
Every few weeks or so, however, the messages start sending one minute later than they're supposed to. It started with just sending one minute late, so I adjusted the time in the job to one minute later, but the delay just keeps getting worse. Now the messages are sending 7 minutes later than they're supposed to according to the time I originally set in the job.
I'm very much an amateur, and I'm not sure what might be causing this.
The only thing I have been able to come up with to remedy the problem is adjusting the time in the job, but that's definitely not an ideal solution. It works for a little while, but then the message just delays even more.
The issue still persists even after I've reset the bot, refreshed the js files, etc. as I've been working on other bot functions.
Is there a way to reset those Cron tasks specifically, so they're running on time again. Is the reason just because I have other stuff going on in the command file where those jobs are started? If so, how could I remedy that besides moving it to a separate file?
Related
I have been looking for a time based persistent scheduler. I looked into some applications (Agenda, node-cron, node-schedule). But I couldn't find anything that satisfies my criteria.
So my applications sends out reminders to our customers based on their event timings. I am hesitating to run a regular cronjob because I have to run every 15 mins or so in this case. And for each cronjob, I have to make a database call. I am trying not to use resources unnecessarily.
In addition to that, I am already running a lot of cronjobs. But in my case, when the job is completed, I want the cron to get cancelled/finished; not live on memory until the server restart happens.
I tried using the above specified applications by setting exact timestamps (agenda, node-cron, node-schedule). But the cron lives on forever even after the job is completed, and if i restart the server, all the scheduled jobs are cron. So persistence is also an issue I am facing.
My server uses node js. If there are any other languages/tools to make this work, I am all ears.
Looking forward to your help.
I tried following this solution. But this solution is for one predefined event. In my case, the number of reminders to be sent out are dynamic and jobs are to be scheduled on the fly.
I have an issue currently where I've got a cron job set to run at midnight each day to reset daily API requests for a service that I run. The job failed recently which caused me a whole bunch of headaches and I've been trying to find a solution to monitor all of my cron jobs so I don't have a situation like this happen again.
I haven't been able to find a sufficient solution however, and in response I am considering creating a platform that allows you to monitor cron jobs, see logs (and past logs), last run date, failure/success of the last run, etc... in real-time and would notify you if your job hasn't completed within a specified window of time or the job failed.
I believe this might be a pain point and a good solution for others as well.
What are you thoughts? Do you think that this would be useful, have any suggestions, or just think this would be a waste of time?
Did you hear about Rundeck? (https://www.rundeck.com/open-source)
It looks like it's exactly what you're looking for.
You install it on a server, and it's like a Web UI for a crontab.
You define jobs you want to run using the Web UI, how often you want them to run and you can see some history of the past executions, their status and their output. You can also see when the next execution will happen.
I think there are also some alerting features to notify you if a job is on failure. I'm not sure if it can notify you based on the job execution time though.
This might be a good fit for what you're looking for.
2 years later, I am asking myself exactly the same questions ) Definitely you should have created such service already, haven't you? Every backend coder needs this time from time, in theory. I'm surprised this question hasn't received enough activity/voting. I got an answer leading to this though: https://uptimerobot.com/cron-job-monitoring/ that might be a good solution. Need to test it out. It does not seem to be promoted enough, as it's not easy to find. Also there is https://cronitor.io/docs/cron-job-monitoring that has ability to transmit (somewhat limited) telemetry data, +a lot of SDKs to be used from within programming languages.
Now my Python web app spends so much time data-crunching that PythonAnywhere assumes that the app has crashed and times out. (>5 mins = timeout)
My plan is (ultimately) to deliver the output to users by email, so they dont have to wait around anyway. ("Please check your email in 10 mins for your report").
I thought about doing a screen "refresh" periodically during the data-crunching to keep pythonanywhere happy - BUT if users close the browser then this isnt going to work.
How can I avoid a timeout and keep the app running for 10-15 mins without a browser?
Joe
PythonAnywhere dev here -- I think we've already discussed this over email, but I'll post what I said here just in case it's useful for other people.
A good option for stuff that takes a long time to run is to refactor it into a script that you can run periodically, and then schedule that on the "Tasks" tab. If you have a paid account, you can schedule up to 20 hourly tasks (we can bump that up if you need more), so to make the script run every (say) ten minutes, you could schedule it at 2 past the hour, 12 past the hour, and so on. If you need the script to process data that comes from the user via your website, you could make your view write something to the database with the details of what needs doing, then the scheduled task could pick that up, process it, and put the results in the DB for the website to pick up.
We've got a help page with a bit more information here.
We have an Azure Webjob running on one of our websites that is supposed to run once a day, during the night. This generally processes some data, updates a few records ... It's a process that runs for a few minutes and in the end simply prints "OK".
The Webjob is set to run at 10 PM.
Now, we notice in our logging, that it does indeed run at 10PM, and then runs again at 10:01PM and 10:02PM and 10:03PM. It runs four times.
What I suppose is happening is that the job is taking some time to process (it takes about three minutes on our production environment) and the Azure Webjob keeps triggering it once every minute until it receives a response.
Can someone confirm or deny this? I've tried reading the documentation and googling for this specific problem, but couldn't find much information about it, other than that it might show this behavior if an exception is thrown (which is definitely not the case).
Can this behavior be configured in some way?
I'm getting a lot of reports about a problem with delayed notifications from people using my timer app on windows phone 8.
http://www.windowsphone.com/en-us/store/app/timer/38ac6043-0d3e-471a-9527-a20d1ef8521b
There was always the problem that Alarms added to the ScheduledActionService aren't very accurate. I fixed the problem when the app is running by adding and removing a dummy alarm shortly after the real alarm counted to 0. This "woke up" the ScheduledActionService, it checked for expired alarms and showed the notification. This behaviour changed with WP8.
My little hack doesn't work any more and a lot of people seems to be quiet frustrated about it. I also got feedback that sometimes the alarms don't work under the lockscreen at all. Sadly I can only reproduce the first problem on the emulator. Has anyone experienced similar behaviour?
Is there any other possibility to tell the ScheduledActionService to check it's alarms?
Is it possible to hide my app in the store on WP8 devices up to the time when I corrected this behaviour?
regards,
Christian
I ran into a similar problem. I created a basic voice enabled timer app. The problem I had was if someone sets the alarm to go off in 20 seconds and I create that scheduled action well its not going to work for one minute.
"Alarms and Reminders are accurate only within a range of one minute. In other words, the notification can be launched up to one minute after it was scheduled." -msdn
I know you know this but I thought I would include it for others reading. I ended up initially creating all alarms via a timer in code and if the user exits the app only then do I create a scheduled action. If the user tries to close the app and there is less than one minute remaining I show a message box I don't remember the exact warning but its along the lines of the phone cannot show the alarm for one minute after exiting the application.
Maybe you could split the options up for the user?
an accurate timer that only works when the app is open and you can control in code down to the second, and a more generic timer that works outside of the app that would only allow one minute increments.