# 使用Cron運行Ruby的問題

mkdir #{HOST} -p


It works fine by: ruby mycode.rb

0 * * * * ruby ~/backup.rb >> backup.log

## 最佳答案

Usually, the first filename argument stops option processing and everything that comes after that will be treated as a filename. So, since #{HOST} is a filename, everything after that will also be treated as a filename, which means that the call will be interpreted as "make two directories, one named #{HOST} and the other named -p" If you look for example at the specification of mkdir, it is simply illegal to pass an option after the filenames.