![](/img/trans.png)
[英]Stop command execution after a while and execute next command in a shell script
[英]Execute command after the completion of Shell Script
我正在尝试在执行Shell脚本后执行命令。 到目前为止,以下代码是我尝试过的:
#! /bin/bash
exec >> /tmp/foo.log
#$REPO and $AUTHOR are environmental varibles
echo "test" >> /tmp/foo.log
echo $REPO >> /tmp/foo.log
echo $AUTHOR >> /tmp/foo.log
exit 0
cd /var/www/html/websvn
php remove_commits.php $REPO $AUTHOR
上面的脚本由于某种原因无法正常工作。 我怎样才能解决这个问题? 急需您的帮助。
假设您要执行cd命令和php脚本,则需要删除出口0。这将退出脚本。
下面的代码在foo.sh成功后运行php。
$ ./foo.sh && (cd /var/www/html/websvn; php remove_commits.php $REPO $AUTHOR)
exec >> /tmp/foo.log
这会将以下命令的所有输出重定向到/tmp/foo.log
。 不用于执行命令。 请参阅http://wiki.bash-hackers.org/commands/builtin/exec
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.