我有一个bash脚本,1)使用backup
gem备份我的应用程序,2)将结果上传到我的Box帐户。
#!/usr/bash
PATH=/etc/profile:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
cd ~
backup perform --no-quiet -t eds_backup > ~/output.txt
#use Python script to send archive to Box
source `which activate` box_backup
python ~/box_backup/main.py
从命令行手动运行时,它按预期运行。但是,当我将其设置为crontab时,它会失败。这是crontab。
PATH=/etc/profile:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
* * * * * bash -lc ~/scripts/backup.bash > /tmp/eds_backup.output
此作业运行后, /tmp/eds_backup.output
是一个空文件。
以下是备份模型的内容。电子邮件和数据库的密码保存在/ etc / profile
中Model.new(:eds_backup, 'Back up for my project') do
archive :my_archive do |archive|
# Run the `tar` command using `sudo`
# archive.use_sudo
archive.add "path/to/my/project"
end
store_with Local do |local|
local.path = "/where/to/store/backup"
end
compress_with Gzip
notify_by Mail do |mail|
mail.on_success = true
mail.on_warning = true
mail.on_failure = true
mail.from = "me@email.com"
mail.to = "me@email.com"
#mail.cc = "cc@email.com"
#mail.bcc = "bcc@email.com"
mail.reply_to = "me@email.com"
mail.address = "smtp.office365.com"
mail.port = 587
mail.domain = "mydomain.com"
mail.user_name = "me@email.com"
mail.password = ENV['EMAIL_PW'] #this variable is kept in /etc/profile
mail.authentication = :login
mail.encryption = :starttls
end
database MySQL do |db|
db.name = "dbname"
db.username = "db_user"
db.password = ENV['EDSACCESS_PW'] #this variable is kept in /etc/profile
db.host = "localhost"
db.port = 3306
db.prepare_backup = true # see https://github.com/meskyanichi/backup/pull/606 for more information
end
end
backup
日志没有输出。
最后这是/ var / log / syslog
给出的输出Apr 8 15:48:01 edsdata CRON[25092]: (stoebelj) CMD (bash -lc ~/scripts/backup.bash > /tmp/eds_backup.output)
Apr 8 15:48:01 edsdata CRON[25091]: (CRON) info (No MTA installed, discarding output)
我已获得执行bash脚本的全局权限。关于我做错了什么想法?
更新:
为简化起见,我编辑了我的crontab
* * * * * backup perform --no-quiet -t eds_backup
备份隐式保留自己的日志,等待几分钟后不会显示任何新条目。似乎crontab没有调用任何东西