Schedule a job to run at a given time on Parse - parse-platform

Is it possible to schedule a job to run at a certain time in Parse? For example, I have a calendar app and I want to remind users they have something on in say 10 minutes.

Yes. It is called "Background Jobs" and is a part of Cloud Code.
See guide here: https://parse.com/docs/cloudcode/guide#cloud-code-advanced-background-jobs

Related

How to run command after hours from controller action in laravel?

I need to notify users of incoming end time of created data. Let's say need to notify the users after 3hrs of created data. But I dont want to run cron job every hour because this will slow down the system.
You can queue a command then add a delay to it.
use Illuminate\Support\Facades\Artisan;
Artisan::queue('your:command')->delay(60 * 60 * 3);
I haven't tried to delay a queue for hours. That's why I think a scheduled task is more reliable as you know the time when it runs.
Laravel has a Task Scheduler pretty efficient to work with cron.
You only have to configure it once to run once a minute and Laravel does the rest for checking when it needs to run.
The syntax is pretty simple and you find all available configurations on your codebase.
https://laravel.com/docs/9.x/scheduling
This hardly slows down the system since Laravel only runs the necessary.

How can you program a cronjob to run only ONCE after 12am and 12pm

I am given the following problem:
There are two shifts. One shift starts at 12am and the other at 12pm.
At the beginning of each shift, generate some tasks (details not important).
Ordinarily, this is a trivial problem that can be solved with crontab. However, my company is running on Heroku and the Heroku Scheduler has the following interesting properties:
It can only run every 10 mins, hour or daily,
You cannot time when the scheduler will actually start. If you scheduler is running every 10 mins, all you can expect is that it will run between 4:00am to 4:10am.
It is possible that the scheduler encounters some error and crash. When this happens, the scheduler will restart immediately. As an example, if the scheduler crashed at 4:00 while it was running, it might run again at 4:01.
Is it possible to implement a cronjob that:
executes once only once after 12am and 12pm
without needing a database to track its execution time?
One way I can think of doing this would be to have some cron server (not on Heroku) which runs a script at 12am and 12pm.
The script invoked by the cron could use the Heroku Platform API to spin up a one-off dyno in your Heroku app (using the Dyno Create endpoint).
This method satisfies your requirements of executing only once at 12am and at 12pm, WITHOUT using a DB to track execution times.
The drawback of this method is that it is not a "pure Heroku" solution, and requires you to maintain some "external" server to trigger your cron jobs.
If you don't like the ideas of maintaining your own cron server for that, you could use some cloud solution to schedule your script. For example, I would imagine you could do this for free using AWS Lambda with Scheduled Events.
In this case, you would schedule your lambda function to run each day at 12am and 12pm, and your lambda function would spin up your Heroku one off dyno.
Of course if you would be willing to add some form of DB to your Heroku app, you could easily create a "pure Heroku" solution.

Using ruby and sinatra how can I schedule a script to run (at an unpredictable time) in the future?

I am designing a reminder type app. Somebody enters into a form, for example, "call me at such and such a time on such and such a day in the future to remind me of something".
This is put into a postgres database. Obviously lots of people (hopefully) will be doing this and scheduling different things at different times in the future.
So, my question is how can ensure that my app checks the database for things it has to do at the right time? Can I:
a) should I, when the entry is made, create an automated script to execute at the time necessary to perform the reminder function? If so, how?
b) get my app to check the database every minute, again if so how? This would seem a huge waste of resources.
Sorry I cannot provide any code for this but I have no idea where to begin. all help gratefully received.
Thank you!
You might wanna use a background job framework like Sidekiq. Sidekiq supports scheduled jobs like this:
Notifier.perform_at(a_time_object, message_to_send)
It seems like Sidekiq also works with Sinatra.
For that particular task I prefer whenever https://github.com/javan/whenever

Schedule a job at a specific time from code in Parse

I am using Parse.com backend for my application and I need to perform a particular job at a specific time and notify the mobile app via Push notification.
I cannot find a way to do it from code. I see we can only schedule jobs in Parse using its UI.
A common solution is to have a job that runs every 5 minutes, checking for a record that's due to be processed and comparing the time to now. If it is due then do the work and send the notification, marking the job as done (or just deleting the record depending on your needs).

Scheduling Jobs On web server

We Want to Create an online game like this.I think that ,this type of games have a scheduling software on web server. For Example : Player Click to create a resource And resource creation will be take a moment like 20 Minutes.(Every resource creation time will be different). This message will send to web server application but this message will not processed at same time for example must be processed after 20 Minutes. The web server application after getting the message must be put the order in the Queue.
We have Some big problems :
1- The Jobs must be complete by the web server application Even the player Exit the Game. I think that we must create something like Windows service on Web Server. Can we do it? or Is there a better way?
2- The Second problem depended on problem 1 .Because we will have many Jobs (every player can create 20,30 Jobs in every Loggin and we will have thousands of users) , So Our Scheduling System Must be Work On time . it's possible that , there is 100 , 1000 jobs in a same second , if application Can't Done Jobs in him Second will be use the next second Time and the next second jobs will shift to next second and etc. How We can do for this problem ?
Platform : .Net 3.5 On Windows 2003 Web server
Cheers
Asad Safari
Agile Coach , Scrum Master
On unix, use cron to schedule a script to run every minute - the script then handles all the jobs.
http://en.wikipedia.org/wiki/Cron
Well the specific answer would depend on which technology/language/platform you're using. In java, check the scheduling services provided by Quartz to schedule jobs; and check JMS/MDBs to implement the asynchronous event processing you mention in question 2.
I think my answer won't exactly fit your question but it will solve your problem. Both points at once.
First at all, why do you want to automatize the execution of this events? As far as I understand, you need to give the player access to his resource if and only if he created the resource an especific time ago.
Well, this is my solution:
Insert a field in your resource model class named usable_since or something like that and, when the player create his resource, just set it the value of this field to the current time plus the desired waiting time.
In this way you beat the two problems:
the resource will be usable even if the player gets offline and
you just won't need to set up so big job handler, even with a million users.
I hope it helps. I wish you the best luck in developing the game. Make it fun!
I had a somewhat similar question, as I'm also developing an application which relies on server-side scheduling: Job-Scheduling in Play! Framework. I use the Play Framework (Java) and it works like a charm; except I have no experience in how many jobs can be scheduled concurrently without bringing the server to its knees.

Resources