Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Given</p> <pre><code>*/30 * * * * php /var/www/html/result.php </code></pre> <p>There are multiple possibilities why it is not working:</p> <p>1) First of all it is important to check if the simple execution of <code>php /var/www/html/result.php</code>. This is required. But unfortunately, accomplishing this does not mean that the problem is solved.</p> <p>2) The path of the <code>php</code> binary has to be added.</p> <pre><code>*/30 * * * * php /var/www/html/result.php </code></pre> <p>to be changed to</p> <pre><code>*/30 * * * * /usr/bin/php /var/www/html/result.php </code></pre> <p>or whatever coming from <code>which php</code>.</p> <p>3) Check the permission of the script to the user running the crontab.</p> <p>Give execution permission to the file: <code>chmod +x file</code>. And make sure the crontab is launched by a user having rights to execute the script. Also check if the user can access the directory in which the file is located.</p> <p>4) To be safer, you can also add the php path in the top of the script, such as:</p> <pre><code>#!/usr/bin/php -q &lt;?php ... ?&gt; </code></pre> <p>5) Make sure the user has rights to use crontab. Check if he is in the <code>/etc/cron.d/deny</code> file. Also, make a basic test to see if it is a crontanb or php problem.</p> <pre><code>* * * * * touch /tmp/hello </code></pre> <p>6) Output the result of the script to a log file, as <a href="https://stackoverflow.com/questions/7397469/why-is-crontab-not-executing-my-php-script/7397498#7397498">William Niu suggested</a>.</p> <pre><code>*/30 * * * * /usr/bin/php /var/www/html/result.php &gt; /tmp/result </code></pre> <p>7) Use the <code>-f</code> option to execute the script:</p> <pre><code>*/30 * * * * /usr/bin/php -f /var/www/html/result.php &gt; /tmp/result </code></pre> <hr> <p><strong>To sum up</strong>, there are many possible reasons. One of them should solve the problem.</p>
 

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