cron tab not working

时间:2015-09-01 21:25:24

标签: php crontab

I have this code bellow to run in command line but is not working. I tried in command line to run without the cron tab and it works. Anyone knows how to fix it ? Thanks in advance.

*/5 * * * * /usr/bin/php /var/www/html/ulchemdb/File_upload/uploads/crontab.php > /dev/null 2>&1

3 个答案:

答案 0 :(得分:1)

  1. Where is your php is? It can be clarified with "which php" or "whereis php" commands. Use this path as your php executable path.
  2. Try to execute this command manually. Is it works? If no => problem not in crontab.
  3. If yes => remove output redirecting to dev/null for a time (remove part " > /dev/null 2>&1"), use redirecting to log file, for instance:

    */5 * * * * PATH-TO-PHP/php /var/www/html/ulchemdb/File_upload/uploads/crontab.php > /var/log/php.log 2>&1

  4. Investigate a log after some time. Is there something? If no => make sure you script have some output.

答案 1 :(得分:1)

Crontab line is ok:

*/5 * * * * php /var/www/html/ulchemdb/File_upload/uploads/crontab.php

I think the problem with script.
try to run it manualy:

php /var/www/html/ulchemdb/File_upload/uploads/crontab.php

or if You don't have opportunity to get to console do following:

  1. enable error reporting
  2. add line to then end of crontab.php:

    echo "\nCOMPLETED SUCCESSFULY\n"
    
  3. add this crontab line:

    */5 * * * * php /var/www/html/ulchemdb/File_upload/uploads/crontab.php >> /var/www/html/ulchemdb/File_upload/uploads/crontab.log
    

Also You can share with us Your code, we'll try to help You somehow.

答案 2 :(得分:0)

try

*/5 * * * * php /var/www/html/ulchemdb/File_upload/uploads/crontab.php > /dev/null 2>&1