Skip to content
Advertisement

I want to run daily php file with html and js content crontab

I am new to this topic and I have developed a .php file, which has an html code inside, which makes a series of functions through javascript and this through ajax, executes a php code, which registers data in the database, the code works correctly, when opening the url, internally it does the whole process. But what I want now is to schedule this code to be executed every day at a certain time, but when doing it directly with my hosting, it returns the html code and does not execute it. I also used cron-job.org and it returns the same, it returns all the html code in text format, but it does not execute the functions and others that I have in javascript and php. I would appreciate if you could help me.

Advertisement

Answer

What I would do, create a new PHP file that contains all function calls that normally would be executed through AJAX requests. Then schedule this new PHP file in a cronjob.

You could also script the whole thing as if you were a visitor of the page through a headless browser, for example PhantomJS or Selenium. And then schedule that.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement