linux - 使用 `at' 执行 bash 脚本

标签 linux bash batch-processing

我制作了一个调用 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/

相关文章:

linux - 从压缩目标文件的存档文件列表中查明存档文件

bash,获取文件句柄的 mime 类型

linux - Grep for String 在对应行打开

sql-server - 批量调用存储过程时SQLCLR状态持久化

python - 如何使用gzip有效地将许多小文件压缩为许多小.tar.gz文件?

ruby-on-rails - 防止 delayed_job 后台作业在单台服务器上占用过多 CPU

linux - 如何将命令的输出放入bash变量中

shell - 在linux中将xlsx批量转换为csv,所有带有模式的工作表(如果有数据)

xmllint - 无法读取特殊字符

linux - 面对 ORA-01033 : ORACLE initialization or shutdown in progress due to data file issue