Redmine在使用Whining Redmine计划任务
Redmine 在使用Whining Redmine插件时,需要创建计划任务,根据Whining Redmine安装和配置指导,计划任务如下:
0 7 * * 1,2,3,4,5 www-data cd /path/to/redmine && /usr/bin/rake redmine:send_whining days=7 RAILS_ENV="production"
但是经过多次测试,均为能成功,一开始报邮件错误
Apr 30 15:01:01 10-10-1-158 postfix/sendmail[18138]: fatal: parameter inet_interfaces: no local interface found for ::1
解决方案:
[root@Captain redmine]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
注释掉 ::1行:
[root@Captain redmine]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
# ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
后又报错:
rake aborted!
crontab rake aborted! cannot load such file -- bundler/setup
.......
.......
.......
.......
.......
NameError: method `source' not defined in Gem::Specification
.......
.......
解决方案:
一、如果是使用计划任务+脚本执行,需要在脚本中做特殊处理:
定时计划任务:
[root@Captain redmine]# vi /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 8 * * * 1,2,3,4,5 root /var/redmine/crontab.sh
脚本文件:
[root@Captain redmine]# cat crontab.sh
#!/bin/bash
source /etc/profile
Prog_dir=/var/redmine
Day=2
cd $Prog_dir
rake redmine:send_whining days= $Day RAILS_ENV="production"
需要在脚本中增加
source /etc/profile
二、如果使用计划任务(crontab)直接执行
报错如上所述不在赘述
解决方案
计划任务指令如下:
[root@10-10-1-158 redmine]# vi /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 8 * * * 1,2,3,4,5 root cd /var/redmine && source /etc/profile && rake redmine:send_whining days=2 RAILS_ENV="production" &> /var/redmine/log/crontab.log
同样需要调用source
# 搞定,本人小白,这只是我自己的学习和总结