我想在运行 at 命令之前测试 at time 参数。用例是我想在不同的时间在不同的计算机上运行 at 命令,所以我想首先存储 at 参数,这意味着我想在第一次输入它时检查它。
示例之前:
$ atarg1="now+7mintes"
# I would like to check the above *before* running this
$ at $atarg1 <<< "echo hi there"
syntax error. Last token seen: t
Garbled time
最佳答案
如果作业成功,您随时可以从队列中删除该作业。这显然存在竞争条件 - 万一命令在提交和删除之间从队列中执行,您将不必要地运行命令。不过,当您不想运行 true
时,影响非常小。
if success=$(at "$atarg" <<<true); then
sed 's/^job \([1-9][0-9]*\) at .*/\1/' <<<"$success" | xargs atrm
exit 0
else
exit $?
fi
关于linux - 测试命令时参数的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37153631/