jdo*_*dog 2 svn shell cron awk quoting
我有以下命令来显示对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
Run Code Online (Sandbox Code Playgroud)
它在命令行中工作正常.
当我将其粘贴到crontab中时,我收到以下错误消息:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `)'
/bin/sh: -c: line 1: syntax error: unexpected end of file
Run Code Online (Sandbox Code Playgroud)
如何引用它?
使用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
Run Code Online (Sandbox Code Playgroud)
加
cron 0 22 * * * /opt/cron/dosomething.sh
Run Code Online (Sandbox Code Playgroud)