Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Method 1: Execute the script using php from the crontab</p> <p>Just like how you call your shell script (As show in our crontab 15 examples article), use the php executable, and call the php script from your crontab as shown below.</p> <p>To execute myscript.php every 1 hour do the following:</p> <h1><strong>crontab -e</strong></h1> <pre><code>00 * * * * /usr/local/bin/php /home/john/myscript.php </code></pre> <p>Method 2: Run the php script using URL from the crontab</p> <p>If your php script can be invoked using an URL, you can lynx, or curl, or wget to setup your crontab as shown below.</p> <p>The following script executes the php script (every hour) by calling the URL using the lynx text browser. Lynx text browser by default opens a URL in the interactive mode. However, as shown below, the -dump option in lynx command, dumps the output of the URL to the standard output.</p> <pre><code>00 * * * * lynx -dump http://www.thegeekstuff.com/myscript.php </code></pre> <p>The following script executes the php script (every 5 minutes) by calling the URL using CURL. Curl by default displays the output in the standard output. Using the “curl -o” option, you can also dump the output of your script to a temporary file as shown below.</p> <pre><code>*/5 * * * * /usr/bin/curl -o temp.txt http://www.thegeekstuff.com/myscript.php </code></pre> <p>The following script executes the php script (every 10 minutes) by calling the URL using WGET. The -q option indicates quite mode. The “-O temp.txt” indicates that the output will be send to the temporary file.</p> <pre><code>*/10 * * * * /usr/bin/wget -q -O temp.txt http://www.thegeekstuff.com/myscript.php </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload