简体   繁体   English

如何防止CronJob创建日志文件?

[英]How can I prevent creating log files by CronJob?

I have a Cronjob. 我有一个Cronjob。 My command is that: wget mysite.com/bot.php But this command will automatically creates log files that names are like: 我的命令是: wget mysite.com/bot.php但是此命令将自动创建名称如下的日志文件:

  • bot.php bot.php
  • bot.php.1 bot.php.1
  • bot.php.2 bot.php.2
  • bot.php.3 bot.php.3
  • etc... 等等...

How can I prevent this? 我该如何预防?

Thanks! 谢谢!

I assume you're trying to run your script without storing any information locally. 我假设您正在尝试运行脚本而不在本地存储任何信息。

Try adding &> /dev/null to the end of your cron command, this will dump the output to /dev/null which is basically a black hole ( anything that ends up here is irretrievable ). 尝试在cron命令的末尾添加&> /dev/null ,这会将输出转储到/ dev / null,这基本上是一个黑洞(到此为止所有内容都是无法检索的)。

An example cron command would be: cron命令的示例为:

*/5 * * * * wget -qO- http://example.com/check &> /dev/null

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

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