简体   繁体   English

在WordPress中调试cron任务

[英]Debugging cron tasks in WordPress

How could I debug cron task run by internal cron functions ? 我如何调试内部cron函数运行的cron任务? My cron task is not firing and I suppose some functions are not declared yet when cron hook takes place. 我的cron任务没有触发,我想当cron hook发生时,某些函数还没有被声明。

It would be great if I can store the errors into some log file? 如果我可以将错误存储到某个日志文件中会很棒吗? Any ideas? 有任何想法吗? Thanks. 谢谢。

I used Core Control plugin to see if everything is all right. 我使用Core Control插件来查看一切是否正常。 The my_task_hook and hooked function too, the "due time" is changing...so something else must be wrong. my_task_hook和钩子函数,“到期时间”正在改变......所以别的东西一定是错的。

I found the wp-cron dashboard plugin http://wordpress.org/extend/plugins/wp-cron-dashboard/ very helpful. 我发现wp-cron仪表板插件http://wordpress.org/extend/plugins/wp-cron-dashboard/非常有帮助。 Using it I was able to see what cron tasks were working or not. 使用它我能够看到cron任务是否有效。

I also found that the docs on the cron functions weren't very clear. 我还发现cron函数的文档不是很清楚。 When setting up a wp cron task make sure you add the function as an action using add_action only then can you run wp_schedule_event on the task. 在设置wp cron任务时,请确保仅使用add_action将该函数添加为操作,然后才能在该任务上运行wp_schedule_event。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM