Executing php with crontab

后端 未结 6 1002
误落风尘
误落风尘 2020-11-27 19:08

I\'m trying to run a php-script on a scheduled basis. So I\'d thought crontab was a good idea. The server I\'m using is on Linux which I\'m not that familiar with. So the pr

6条回答
  •  盖世英雄少女心
    2020-11-27 19:32

    You can also use env, it will find and launch php for you:

    /usr/bin/env php /var/www/some/path/script.php
    

    Or you can place a shebang in your script.php (first line):

    #!/usr/bin/env php
    

    then make it executable, and make crontab call it directly, like in your first example:

    5  * * * * /var/www/some/path/script.php
    

提交回复
热议问题