簡體   English   中英

使用`at'執行bash腳本

[英]using `at' to execute bash script

我制作了一個bash腳本,該腳本調用jvm來執行jar編。 該腳本運行良好。 我想使用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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM