0

I have a back-end server (PHP 7.2) where i call a .php file from index,html every some seconds.

<!DOCTYPE html>
<html>
<head>
    <title>Title of the document</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
    <script>
        setInterval(
            function() {
                $('#content').load('temp.php');
            }, 30000);
    </script>
</head>
<body>
    <title>Auto Load Page in Div using Jquery</title>
    <h1>Auto Load Page in Div</h1>
    <div id="content"> Please wait .. </div> 
</body>
</html>

Is this possible this page run without to open it from browser? Now i run it local with xampp. Can i just start apache and make that request automated? Thank you in advance. I hope you understand what i ask.

K. Efkas
  • 1
  • 3
  • 2
    I'd suggest using a cron job or automator to access the file without a browser. – aynber Jan 16 '20 at 14:06
  • 1
    Cron only has granularity down to the minute, I think. Having something run multiple times per minute may involve another task scheduling system, or perhaps some workarounds like these: https://stackoverflow.com/questions/9619362/running-a-cron-every-30-seconds But yes, as suggested by others above, what you're looking for is to automate a process, not host a web server. – David Jan 16 '20 at 14:09
  • 1
    What's the desired outcome here? I think we're in X&Y territory....https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem – peeebeee Jan 16 '20 at 14:15
  • You can use cron or screen to automate your scripts or programs. Apache is like Nginx, they are used to host website – Hugo Sohm Jan 16 '20 at 14:20
  • What kind of script needs to run every three seconds? – brombeer Jan 16 '20 at 14:26
  • I would like to have something similar to index.html open so to call temp.php page.Like this page is open on the browser all the time and make ajax call. I know that apache is hosting local in my case. – K. Efkas Jan 16 '20 at 14:31

1 Answers1

0

For this method, you need to have a windows based Environment as well as know the location of the php folder. In the assumption that you are in windows environment and know the php installed location, perform the following method. Iam using windows task scheduler and a bat file execution procedure.

  1. First find your php installation folder. Eg : - C:\xampp\php
  2. For my instance php execution file located in - C:\inetpub\wwwroot\OffsiteHelpdesk\reports\reporttwo
  3. Then open a blank text file and use the following code
echo off
REM This adds the folder containing php.exe to the path
PATH=%PATH%;C:\xampp\php

REM Change Directory to the folder containing your script
CD C:\inetpub\wwwroot\OffsiteHelpdesk\reports\reportthr

REM Execute
php pz5adfyrys.php
  1. Change "PATH" and "CD" according yours.Also change pz5adfyrys.php for your php file name
  2. Save the file as .bat format. Also you can execute .bat file and see the result as well before schedule execution.

  3. Please follow the below procedure for scheduling the .bat file through windows file scheduler. https://www.youtube.com/watch?v=EInOL6D5f3Q

cs-87
  • 170
  • 1
  • 12