Ryan Ryan - 3 months ago 10x
Linux Question

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


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

The script runs and accesses the arguments just fine, but the results are never printed to the logfile.log. Also, my logfile.log is chmod 777, so I know it has write access.

Can you fix my syntax?

mik mik

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.