Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I created table account here 5 columns a/c_no date, deposit withdraw balance. I need to insert data automatic after 2 days with date and value of interest. How to code this?
For this you have make a scheduler kind of thing, that runs on scheduled time and do the assigned task with the specified logic. In linux, cron is there for this purpose.
Cron Jobs are used for scheduling tasks to run on the server. They're
most commonly used for automating system maintenance or
administration. However, they are also relevant to web application
development. There are many situations when a web application may need
certain tasks to run periodically. Today we are going to explore the
fundamentals of Cron Jobs.
Reference
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I will try to explain what I am trying to achieve. I am writing laravel json api with MySQL. Imagine user creates record inside my database. What I want to do is perform some kind of operation 24 hours after this record is created. It's something like cron job but what will be the the best solution? Should I run cron for example every 5 minutes and check if expired 24 hours for any of the records? Or maybe there is better solution?
You should use the Laravel queue system for this. When you insert a record in the database, you should create a new delayed job. Set the delay to 24 hours and Laravel will execute the job at that moment.
AfterInsertJob::dispatch()->delay(now()->addHours(24));
cron is fine, but (mysql) databases have events, which can be scheduled. In my opinion, this is really down to your personal taste and therefore more or less off-topic here. I mean an update after 24 hours on the entries is one SQL statement which should be rather fast, unless you have millions of entries ;)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a case where the user wants to be able to add Jobs using the UI, and he should be able to start and stop them at any given time.
So the jobs should be added dynamically at the run time, how can I achieve this functionality with laravel?
You may want to check out the laravel-dynamic-scheduler package. Even if you don't use the package it still can serve as a nice code example for you.
You essentially create a proxy task, and then through that task, can dynamically call other tasks created by users. The proxy task can check a database table of tasks you can have user's manage.
It is essentially using the same method Laravel itself does in the scheduler, as the scheduler itself is really just a proxy for the system's Cron.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
In this tutorial, to run two consumers, I open two consoles and type php worker.php into each.
https://www.rabbitmq.com/tutorials/tutorial-two-php.html
Instead I want to create some workers when a user logs in, and destroy those workers, when logging out. Is this possible within the php framework, If not what route might I take using bash scripts or similar?
[edit: more info]
Under normal circumstance I might spin up a few workers to do some tasks that take a long time. For my website I would like up to eight identical workers for every logged in user. Destroying the workers after use is no so much an issue. But If I spin up 16 workers(for two concurrent users) and a third person logs into my website I would like another 8 workers to be initiated.
I could check the logs each day, find out what was the max concurrent users and spin up the required number manually, but I'm assuming there is a better way.
The answer is: Yes, it is possible. The best solution depends on the project details.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
We have a database table with created datetime and status flag. We would like to update the status flag to the next status if the created date time has elapsed by 30 minutes without any user intervention. How can we achieve this in php.
Create a php file that does this status change in the database and program to execute it every 30 minutes with cron (Linux) or Task Scheduler (Windows).
You have to think carefully about how you design and use your database. Sometimes things are made overly complicated when they don't need to. For instance, in this case you could use a 'datetime' in your table indicating the start time. Any PHP script can now check whether or not the start time started 30 minutes ago, only when this information is actually needed. No need for a flag, cron jobs, etc.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want each time a new lesson is added to the lessons table, a notification send to all students in that grade. Let's say I have 10,000 students in the fifth grade, that means a 10,000 insert operations will be made in the notifications table which is a huge load.
Is there a better idea on how to send notifications to users, knowing that a user can see the notification only ONCE.
It seems that the notification process can be made asynchronously.
I suggest to develop a separate message queue architecture for this scenario. A program will loads newly added data and put them in a queue, then another process can read the queue and (for example send emails to users). You can add more queue consumer to manage more huge data.
Of course you will need a MQ Server.
To get a filling of asynchronous development see http://www.rabbitmq.com/getstarted.html which have good examples of Rabbit MQ ( Rabbit MQ is a opensource java base messaging service).