I have a program/framework that gets triggered using Cpanel Cron Job once a day at 3 AM. This updates a database with commands so that a C++ running on a local server updates or creates new entries in a web server database.
I have wordpress accessing this data via cross database to display this information to the end user, However, my C++ program will not send any data until the Cpanel Cron triggers my framework and sets up the request. I do not wish to setup my cron job for every minute because it will take a massive toll on my web server. But if i have a “refresh” button that will execute the php file, then the C++ program will have its needed parameters to update the database. ( end user will do this once every week in special occasions only )
I can’t setup an include php with a trigger function and setup word press ajax because it will crash WordPress’s enviroment ( especially since the function needs to register with ajax.php so jscrip can call it )
Sorry if its confusing.
3
Answers
jQuery .load() method would do the trick for you. You could also use .ajax method, and jQuery documentation would enforce it, but I prefer the first to display the results:
WordPress has their own system to create crons or “schedule events” as they call it, the only limitance on this is, someone has to visit your site and the system will excecute the cron if the schedule has passed.
for more information about this read here
Also you can use the command line interface library of wordpress, and call through command line differents options for you wordpress like backups, create posts, update the complete wordpress core and plugins, etc.
For more information about this read here
Hope this work for you.
If cron is handled by cPanel there is no need to do any cron related stuff on WP. If you want to do an action on user click you can send ajax req which will execute your desired php. You can use php default exec command to execute your php script
Read about how to use ajax in wp here https://www.smashingmagazine.com/2011/10/how-to-use-ajax-in-wordpress/
more about exec http://php.net/manual/en/function.exec.php
If this is not what you want, please give more info.
To set Cron from WP You can use this reference.
https://codex.wordpress.org/Function_Reference/wp_schedule_event