如何使用参数运行cron作业并将结果传递到日志? [英] How can I run a cron job with arguments and pass results to a log?

查看:151
本文介绍了如何使用参数运行cron作业并将结果传递到日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:

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

脚本运行并访问参数很好,但是则不会将结果打印到logfile.log。此外,我的logfile.log是chmod 777,所以我知道它有写访问。

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.

你能修复我的语法吗?

推荐答案

看起来您正在搜索错误文件夹中的日志文件。
尝试此

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

然后在/ path / to / script文件夹中查找您的日志文件。
它也可能是一个写权限问题。
另外,检查脚本是否有错误。
您的crontab命令似乎确定。

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.

这篇关于如何使用参数运行cron作业并将结果传递到日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆