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

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


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.


Does the command work correctly from the command line?It may be possible that the arguments contain some characters treated specially by shell. In that case you need to quote the whole command to prevent shell from tinkering with the arguments.