简体   繁体   中英

using `at' to execute bash script

I made a bash script that invoke jvm to execute a jar prog. The script works well. I want to use the prog `at' to execute my bash script at some time, but the script only works partly:

#!/bin/bash

touch hello.world
while read line
do
    touch another.hello.world
    name=$line
...
done < "/users/me/readin.txt"

The command I used:

$ at -f myscript.bash now

Only hello.world file was generated, but no another.hello.world . So, there must be something wrong in my script or the command usage. What should I do?

The only probability of another.hello.world file not being created is iteration of while loop is not happening at least once.

So probably input file /users/me/readin.txt is blank.

I suggest you to execute code with set -x option, you will find the reason. It will display the trace of what is being execute.

#!/bin/bash

touch hello.world
set -x
while read line
do
    touch another.hello.world
    name=$line
...
done < "/users/me/readin.txt"
set +x

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM