skip to Main Content

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


  1. 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:

    jQuery("#refresh").click(function(){jQuery("#showresults").load("yourScript.php");});
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. 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/

    your_ajax_func() {
    exec('php your file name.php', $output)
    }
    

    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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search