How can I run a cron job with arguments and pass results to a log?

后端 未结 2 2000
旧时难觅i
旧时难觅i 2021-02-20 17:38

Example:

* * * * * /usr/bin/php /full/path/to/script.php arg1 arg2 > /full/path/to/logfile.log

The script runs and accesses the arguments ju

2条回答
  •  粉色の甜心
    2021-02-20 18:12

    It looks like you are searching for the log file in the wrong folder. Try this

    * * * * * cd /path/to/script.php ; ./script.php arg1 arg2 >> logfile.log
    

    Then look for your log file in the /path/to/script folder. It can also be a write permission problem. Also, check your script for errors. Your crontab command seems OK.

提交回复
热议问题