Cron not passing params to PHP script

前端 未结 3 1625
轻奢々
轻奢々 2021-01-17 03:21

I have a cron job set like

php /home/novinarb/public_html/index.php --uri=\"cron/24satahr\"

but the \'uri\' param doesn\'t get to the php

3条回答
  •  长发绾君心
    2021-01-17 03:54

    I was facing the same problem but was able to fix it after reading the manual entry for php.

    Initially I had something set like:

    /usr/bin/php -f /path/to/php/script.php -c 1426 >> /tmp/script.php.log 2>&1
    

    I was able to fix it by changing the line to:

    /usr/bin/php -f /path/to/php/script.php -- -c 1426 >> /tmp/script.php.log 2>&1
    

    As per the manual entry the syntax is:

    php [options] [ -f ] file [[--] args...]
    

    Also,

     args...        Arguments passed to script. Use '--' args when first argument starts with '-' or script is read from stdin
    

    Going by that, my cron command becomes:

    /usr/bin/php -f /path/to/php/script.php -- -c 1426 >> /tmp/script.php.log 2>&1
    

    and it works!

提交回复
热议问题