How to run python script based on user input timer in php/mysql

Currently built a website that contain field for user to input number in time format.user input This input goes into mysql database when button is clicked. database
I'm currently looking into how I can use this value insert by user and use it as timer to execute a python script, the python script is motor.py which will spin the motor, how can I make it work similar to cronjob. I have tried many different crontab web interface but they do not work as I would like it too. Is there any ways of achieving this? Thank You
Jasmeet SinghAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NerdsOfTechTechnology ScientistCommented:
First, you will probably want to limit the interval to hours and minutes (or increments of 10, 15, 30 minutes, or just hours), unless you are allowed to run CRON JOBS every second or minute which you will probably want to avoid anyway since you should have a buffer in place for processing.

You would set a CRON JOB to run a PHP script (this is your timer: run the CRON every X minutes) which checks the database and runs the PYTHON script and keeps track of the next job(s); in this scenario, you could batch the jobs (for example loop/queue through the jobs that are set/collide at the same time).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gelonidaCommented:
There's multiple approaches.

One approach can be for example:

that the php script stores tasks to be executed a mysql table and that you have a cronjob
that executes each minute and checks whether there is any task in the mysql table, that has to be executed now.
If no it aborts
if yes it executes the task

Another one is to create a long running python script (a service that has to be started on the server),
that polls regularly the mysql table and executes the tasks to be done.

For python you could use frameworks / modules like celery.
However I don't know the equivalent for php.
0
NerdsOfTechTechnology ScientistCommented:
Split evenly between both expert's viable solution sets.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.