我知道已经有一百万个问题,但我觉得我已经读完了所有这些 . 我认为其中一些可能是我对crontab如何工作的基本理解,因为我还不是Linux的专家 .

我想每天用crontab运行一个ruby脚本 . 我一直试图使用 crontab -ecrontab -e 测试它 .

只是为了确认我做得对,一旦我在crontab -e,我写出我的命令,然后“WriteOut”,然后输入保存,对吧?我的crontab如下所示:

# Edit this
file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).#
                                                                  # For example,
 you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron($#
                                                                  # m h  dom mon
 dow   command

01 * * * * ruby /home/testcron.rb >> /home/testruby 2>&1

我很确定所有奇怪的换行都是由于我无法进行任何更广泛的gitbash .

我试过的事情:

  • 01 * * * * /usr/local/rvm/rubies/ruby-2.2.1/bin/ruby /home/testcron.rb

  • 基于这个问题定义Shell和BASH_ENV(我认为正确吗?),Crontab not running ruby script .

  • 使用此 01 * * * * ruby /home/testcron.rb >> /home/testruby 2>&1 进行日志记录,但日志永远不会出现,因此看起来ruby脚本未运行 .

  • 我试过 grep CRON /var/log/syslog ,它给出了以下内容

8月29日07:17:01 aarmora CRON [18387] :( root)CMD(cd /&& run-parts --report /etc/cron.hourly)8月29日08:17:01 aarmora CRON [21194] :( root) CMD(cd / && run-parts --report / etc / cron.hourly)8月29日09:17:01 aarmora CRON [23532] :( root)CMD(cd / && run-parts --report / etc / cron . 每小时)8月29日10:17:01 aarmora CRON [24551] :( root)CMD(cd / && run-parts --report / etc / cron.hourly)8月29日11:17:01 aarmora CRON [24910] :( root)CMD(cd / && run-parts --report / etc / cron.hourly)8月29日12:17:01 aarmora CRON [25275] :( root)CMD(cd /&& run-parts --report / etc / cron.hourly)8月29日13:17:01 aarmora CRON [25662] :( root)CMD(cd /&& run-parts --report / etc / cron.hourly)8月29日14:17:01 aarmora CRON [25940] :( root)CMD(cd / && run-parts --report / etc / cron.hourly)8月29日15:17:01 aarmora CRON [26114] :( root)CMD(cd / && run-parts --report / etc / cron.hourly)8月29日16:17:01 aarmora CRON [26517] :( root)CMD(cd / && run-parts --report / etc / cron.hourly)8月29日17:17:01 aarmora CRON [ 26917] :(罗t)CMD(cd / && run-parts --report / etc / cron.hourly)8月29日18:17:01 aarmora CRON [27368] :( root)CMD(cd / && run-parts --report / etc / cron.hourly)

我究竟做错了什么?我该如何更好地调试?