Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby gem是否可以保留crontab文件中的现有行?_Ruby_Environment Variables_Crontab_Whenever - Fatal编程技术网

Ruby gem是否可以保留crontab文件中的现有行?

Ruby gem是否可以保留crontab文件中的现有行?,ruby,environment-variables,crontab,whenever,Ruby,Environment Variables,Crontab,Whenever,我正在使用: Ruby 1.9.2 每当0.7.2 capistrano 2.9.0 capistrano分机1.2.1 我在部署时与Capistrano一起使用Anwhere来管理我的crontab文件 我注意到它每次都完全重写我的crontab文件 我希望能够在cron中设置环境变量来控制PATH和MAILTO设置,这是常规的cron环境变量 是否有一种方法可以确保不覆盖整个crontab文件,以便我可以向crontab文件中添加自定义项并确保它们将持续存在?是的,您可以这样做。您只需为

我正在使用:

  • Ruby 1.9.2
  • 每当0.7.2
  • capistrano 2.9.0
  • capistrano分机1.2.1
我在部署时与Capistrano一起使用Anwhere来管理我的crontab文件

我注意到它每次都完全重写我的crontab文件

我希望能够在cron中设置环境变量来控制PATH和MAILTO设置,这是常规的cron环境变量


是否有一种方法可以确保不覆盖整个crontab文件,以便我可以向crontab文件中添加自定义项并确保它们将持续存在?

是的,您可以这样做。您只需为正在写入crontab的任务分配一个标识符:

whenever --update-crontab some_identifier_name
它将在crontab中生成一个条目,如下所示:

# Begin Whenever generated tasks for: some_identifier_name
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /var/www/test/releases/20120416183153 && script/rails runner -e production '\''Model.some_method'\'' >> /tmp/cron_log.log 2>&1'

# End Whenever generated tasks for: some_identifier_name
然后,无论何时调用上面的命令,它只会更新找到指定标识符的位置