我制作了一个调用 jvm 来执行 jar 程序的 bash 脚本。该脚本运行良好。我想在某个时候使用 prog `at' 来执行我的 bash 脚本,但该脚本只能部分工作:
#!/bin/bash
touch hello.world
while read line
do
touch another.hello.world
name=$line
...
done < "/users/me/readin.txt"
我使用的命令:
$ at -f myscript.bash now
只生成了 hello.world 文件,没有生成 another.hello.world。所以,我的脚本或命令用法一定有问题。我该怎么办?
最佳答案
another.hello.world
文件没有被创建的唯一可能性是 while 循环的迭代至少没有发生一次。
所以可能输入文件 /users/me/readin.txt
是空白的。
我建议你用set -x
选项执行代码,你会找到原因的。它将显示正在执行的跟踪。
#!/bin/bash
touch hello.world
set -x
while read line
do
touch another.hello.world
name=$line
...
done < "/users/me/readin.txt"
set +x
关于linux - 使用 `at' 执行 bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22393616/