4

尝试使用单个 while 循环从用户收集变量并运行顺序“at”命令。单数 at 命令有效,尝试合并失败且没有错误。在这种特殊情况下,输出显示作业已创建,但第一个操作从未完成。

#!/bin/bash
PATH=$PATH:/usr/openv/netbackup/bin:/usr/openv/netbackup/bin/admincmd:/usr/openv/volmgr/bin
read -p "Enter the time and date to deactivate the policies (format - 24hr Month Date example 0400 May 09) : " offtime
read -p "Enter the time and date to reactivate the policies (format - 24hr Month Date example 0400 May 09) : " ontime
while read -r i;
        do
                bpplinfo $i -modify -inactive | at $offtime;
                bpplinfo $i -modify -active | at $ontime
done < /tmp/policies.txt
4

1 回答 1

4

echo 命令将字符串发送到 at,效果很好。

#!/bin/bash
PATH=$PATH:/usr/openv/netbackup/bin:/usr/openv/netbackup/bin/admincmd:/usr/openv/volmgr/bin
read -p "Enter the time and date to deactivate the policies (format - 24hr Month Date example 0400 May 09) : " offtime
read -p "Enter the time and date to reactivate the policies (format - 24hr Month Date example 0400 May 09) : " ontime
while read -r i;
do
    echo "bpplinfo $i -modify -inactive" | at $offtime;
    echo "bpplinfo $i -modify -active" | at $ontime
done < /tmp/policies.txt
于 2015-04-15T18:39:14.143 回答