我有以下命令来显示对subversion存储库的更改
svn log -v -r{$(date +%Y-%m-%d)}:HEAD http://therepository | awk '/^r[0-9]+ / {user=$3} {if (user=="username") {print $1 $2 $3}}' | mail -ne -s'Users SVN commits' email@email.com
它在命令行中运行良好。
当我将其粘贴到crontab中时,我收到以下错误消息:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `)'
/bin/sh: -c: line 1: syntax error: unexpected end of file
如何引用它?
答案 0 :(得分:6)
使用cron时,通过将所有内容放入shell脚本,然后从cron调用shell脚本来避免此类问题的麻烦。
这种方法是常用的,因为:
例如:
dosomething.sh:
svn log -v -r{$(date +%Y-%m-%d)}:HEAD http://therepository | awk '/^r[0-9]+ / {user=$3} {if (user=="username") {print $1 $2 $3}}' | mail -ne -s'Users SVN commits' email@email.com
加
cron 0 22 * * * /opt/cron/dosomething.sh
答案 1 :(得分:1)
最简单的方法是将其保存为bash脚本,然后从cron运行脚本。
(我本来是这个评论而不是答案,但是我不会让我发表评论)
乔