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.
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
)
#!/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.
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...
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.