[英]Run 3 scripts in single folder
I have a script that will run 3 scripts, these 3 scripts i need to put it into a folder called date and time which will take from the system. 我有一个脚本,它将运行3个脚本,我需要将这3个脚本放入名为date and time的文件夹中,该文件夹将从系统中取出。
For example 例如
Can any one suggest me how to solve this problem 谁能建议我如何解决这个问题
You can use smth like this: (contents of your running script, say run3.sh
) 您可以这样使用smth :(正在运行的脚本的内容,例如run3.sh
)
#!/bin/bash
A.sh > date_and_time/A.output &
B.sh > date_and_time/B.output &
C.sh > date_and_time/C.output &
you may also use a sub shell like this: 您还可以使用以下子外壳:
#!/bin/bash
DIRNAME=$(date +"%Y%m%d-%H%M%S")
( $DIRNAME/A.sh ; $DIRNAME/B.sh ; $DIRNAME/C.sh ) > $DIRNAME/Text.txt
If what you want is to have timestamped output directories, this might be a good starting point: 如果您想要的是带有时间戳的输出目录,那么这可能是一个很好的起点:
#!/bin/sh
TIMESTAMP=`date +"%Y-%m-%d-%H:%M:%S"`
OUTPUT="$TIMESTAMP.d"
mkdir -p "$OUTPUT"
A.sh > "$OUTPUT/A.out"
B.sh > "$OUTPUT/B.out"
C.sh > "$OUTPUT/C.out"
echo "Lorem ipsum dolor sit amet..." > "$OUTPUT"/Text.txt
# Let our users know where to find the output...
echo "Output directory: $OUTPUT"
Basically, this script uses the date
command to get the current date and time in a more standardized format and then creates an output directory with the same name. 基本上,此脚本使用date
命令以更标准化的格式获取当前日期和时间,然后创建具有相同名称的输出目录。
Caveat: If you run this script twice within the same computer clock second, the output of the second run will overwrite the first one. 注意:如果您在同一计算机时钟秒内两次运行此脚本,则第二次运行的输出将覆盖第一个。 I'll leave handling this particular corner case as an exercise for the reader... 我将处理这个特殊的案例作为练习供读者阅读...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.