我在 shell 脚本中循环运行 Perl 脚本:
while [ $currentDate -le $toDate ]; do
// code here...
exec /users/my_user/script_name $currentDate
// code here...
done
我已经确认了
while-loop
循环。但是,在运行一次 Perl 脚本后,while-loop
结束。有人可以对此有所了解吗?
最佳答案
您正在使用 exec
. exec
用新程序替换 shell 进程。您可能只想删除 exec
关键词。
exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
Replace the shell with the given command.
Execute
COMMAND
, replacing this shell with the specified program.ARGUMENTS
become the arguments toCOMMAND
.
关于循环中的 Perl 脚本在一次运行后结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17178181/