为什么我的SVN备份的shell脚本,工作在终端正常,但在crontab中失败? [英] why my svn backup shell script, works fine in terminal, but fails in crontab?

查看:196
本文介绍了为什么我的SVN备份的shell脚本,工作在终端正常,但在crontab中失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个RedHat Linux上一个SVN备份脚本。让我们叫svnbackup.sh

它工作得很好,当我在终端运行它。

但是,当我把它放到crontab中,它不会带来svnserve的后面,即使数据被正确地备份了。

什么是我错了?

  killall svnserve的
焦油-zcf / svndir /备份/
svnserve的-r -d / svndir


解决方案

一般情况下,环境是一个cron作业,当它由cron在终端,但不工作时运行的问题。最可能的是,你的路径未设置为包括您保持目录的svnserve

在脚本中使用svnserve的绝对路径或设置PATH恰如其分。

可以调试,部分地通过添加一行如:

  ENV> /tmp/cron.job.env

到脚本看到的是运行cron作业时的环境究竟是如何设置的小

I have a svn backup script in a redhat linux. let's it called svnbackup.sh

It works fine, when I run it in terminal.

But when I put it into crontab, it will not bring the svnserve back, even the data is backuped correctly.

What's wrong with me???

killall svnserve
tar -zcf /svndir /backup/
svnserve -d -r /svndir

解决方案

Usually, 'environment' is the problem in a cron job that works when run 'at the terminal' but not when it is run by cron. Most probably, your PATH is not set to include the directory where you keep svnserve.

Either use an absolute pathname for svnserve or set PATH appropriately in the script.

You can debug, in part, by adding a line such as:

env > /tmp/cron.job.env

to your script to see exactly how little environment is set when your cron job is run.

这篇关于为什么我的SVN备份的shell脚本,工作在终端正常,但在crontab中失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆