I have this small bash script (simplified) which runs on Ubuntu 16.04:
tar zxvf fileNameHere.tgz <-- Untar tgz file in $SRC_DIR
files=$(ls $SRC_DIR)
echo "Extracting $files" >> $APP_LOG_DIR/update.log
mv $SRC_DIR/* $OUTPUT_DIR
shutdown -r now
I've noticed that, after rebooting, only sometimes files are not moved to target and I was wondering if that shutdown command could be the a problem. Is it necessary to call 'sync' before shutting down?
Fixed script with comments:
#!/usr/bin/env bash
# Test if SRC_DIR and OUTPUT_DIR are actual directories
if [ -d "$SRC_DIR" ] && [ -d "$OUTPUT_DIR" ]; then
# Populates the arguments array with the content
# of SRC_DIR rather than parsing the output of ls
set -- "$SRC_DIR/"*
# Prints joined file entries of the arguments array
# while stripping their leading directory path
printf 'Extracting %s\n' "${*#*/}" >> "$APP_LOG_DIR/update.log"
# Moves all the arguments array's entries (the actual
# content of the SRC_DIR) into OUTPUT_DIR
mv -- "$@" "$OUTPUT_DIR/"
shutdown -r now
fi
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.