循环中的Perl脚本在一次运行后结束

czc*_*ong 3 shell perl

我在shell脚本的循环中运行Perl脚本:

  while [ $currentDate -le $toDate ]; do
    // code here...
    exec /users/my_user/script_name $currentDate
    // code here...
  done
Run Code Online (Sandbox Code Playgroud)

我已经确认了while-loop循环.但是,在运行一次Perl脚本之后,while-loop结束了.

有人可以对此有所了解吗?

nan*_*dhp 11

你正在使用exec.exec用新程序替换shell进程.您可能只想删除exec关键字.

exec [-cl] [-a name] [command [arguments ...]] [redirection ...]

用给定的命令替换shell.

执行COMMAND,用指定的程序替换此shell. ARGUMENTS成为争论的焦点COMMAND.