ruby - Cron 和 Ruby.. "puts ` 系统命令`"有什么作用吗?

标签 ruby linux tar cron

关于 cron 和 ruby​​ 的快速问题,

我有一个可以运行的脚本

puts `tar etc..`

我正在尝试调试为什么这个脚本没有像它应该的那样对文件进行压缩......

当我手动调用它时它工作正常并且我也看到 tar 输出..

当 put 在 cron 作业中运行时,它实际上会执行任何操作吗?

谢谢

丹尼尔

最佳答案

来自 crontab 帮助页面:

If standard output and standard error are not redirected by commands executed from the crontab entry, any generated output or errors shall be mailed, via an implementation-defined method, to the user.

我通常为调试 crontab 所做的事情是创建一个记录器:

logfile = File.open('/path/to/log.log', 'rw')
logger = Logger.new(logfile)
logger.debug('something')

关于ruby - Cron 和 Ruby.. "puts ` 系统命令`"有什么作用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5140834/

相关文章:

ruby-on-rails - Ruby:如何存储和显示星期几?

linux - 为什么 NSS 模块在 Linux 上必须以 .so.2 结尾?

c++ - Linux 上的性能分析

c - 获取tar的-C指定文件夹下的所有文件

android - Python:解压android备份?

ruby - UTF-8 中的无效字节序列 (ArgumentError)

iphone - 如何减少 iphone 的 sqlite3 数据库的大小?

c - 在子进程中重定向标准输出是否对父进程也是如此?

powershell - Powershell 中的本地 .tar 提取

ruby-on-rails - 使用\而不是 + 或 << 来连接这些字符串