Cron not passing params to PHP script

前端 未结 3 1628
轻奢々
轻奢々 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 04:00

    A more robust method would be to accept command-line arguments in your PHP script with getopt() or $argv and making it executable. An example with $argv called script.php:

    #!/usr/bin/php
    
    

    Make it executable:

    chmod +x script.php
    

    And execute:

    ./script.php "cron/24satahr"
    

    Will output:

    cron/24satahr
    

提交回复
热议问题