How to run crons from code

Hello everyone!

Someone knows if is possible run the crons from code?

My case:

I have a job that executes all days to respective hour, this job create a specific file with data of some module; but sometime the user could add wrong data to some records, then the user should be able run again this procces.

My idea is: Add a button in my main menu that active the jobs.

Someone knows about it?

Regards!

  •  -

    There are a number of things that you can do.

    • Utilize the Job Queue module I discussed in this post, Developer Secrets | Part 2.
      • You can edit the particular job and reset it to queued and set it to run again. This would be manually done.
    • You can add a custom API endpoint that will allow you to execute your code again.
      • In the implementation; you can either 
        • Add the Job to the Queue again
        • Execute the Job Directly
          • You can execute the job directly via the custom/Extension/modules/Schedulers/Ext/ScheduleTask/YOUR_FILE.php
      • You can then add a button that calls your custom endpoint.
  • Hi Jeff!!

    Thank you so much!

    I made the solution with a custom API, was a good idea!
    Thank you again!

    Regards.