我有一个名为automated_script.rb
的红宝石脚本
我也有一个名为automated_script.sh
的shell脚本
这两个文件目前都位于我的桌面上。
每当我运行ruby automated_script.rb
时,脚本都会按预期运行(所做的只是使用twilio api发送文本消息)
这就是我在automated_script.sh
#!/bin/zsh
/Users/angelgarcia/.rvm/rubies/ruby-2.6.3/bin/ruby /Users/angelgarcia/Desktop/automated_script.rb
当我在终端中导航到桌面并运行时,./automated_script.sh
可以正常工作。
当我简单地跑步时:
/Users/angelgarcia/.rvm/rubies/ruby-2.6.3/bin/ruby /Users/angelgarcia/Desktop/automated_script.rb
在终端中也可以。
但是,在我的crontab中,我有以下内容:
* * * * * /Users/angelgarcia/Desktop/automated_script.sh
这无法正常工作。
只需运行即可:/Users/angelgarcia/Desktop/automated_script.sh
但是由于某种原因,当我将其放入crontab时,它并不会每分钟运行一次。
当我在终端上运行crontab -l
时,我得到了:
* * * * * /Users/angelgarcia/Desktop/automated_script.sh
所以我知道它是活动的。
感谢您的帮助,谢谢!
编辑
这是我的红宝石文件里面的内容
require 'twilio-ruby'
account_sid = 'xxx'
auth_token = 'xxx'
@client = Twilio::REST::Client.new account_sid,auth_token
@client.messages.create(
from: '999',to: '999',body: message
)