As an Linux administrator sometimes some systems produce lots of data in a few hours, normally the data will be stored on a specific partition on the hard drive, but sometimes the systems use shared partitions by default, so, on the same path you will have different data from different sources.
A monitored environment will have threashold configuration to alert if something not normal is happening on the device, so you can take inmediately action, on this example exist a threashold to trigger an alert if the partition $PATH_SOURCE is reaching the 90% of capacity.
If the alert is triggered, the next action is to check what is the content of the $PATH_SOURCE and move the content you are able to move to another partition on the same device, as I mentioned at the begining of the post, probably you have different data from different sources, so you will need to specify the data you want to move.
At this time you are moving data that was listed line by line on a file, so the script will read each line from the file.
The script will read line by line, it will capture and save the result [thtas24_1.txt] on a variable and it will go to the specific path [$PATH_SOURCE] to find the file you want to move, if it matches with any file on the [$PATH_SOURCE] , the file is moved. The script will repeat the process with every line on the file until it is completed.
Also, you will see the start and end time of the process.
[root@localhost securitytweak]# ./move_data.sh
Start: Thu Jan 31 17:57:59 EST 2019
End: Thu Jan 31 18:12:28 EST 2019
Duration: 15:31 minutes
echo ” Moving data…”
echo “Start: `date`”
while read LINE; do
mv $FILENAME $PATH_DEST
done < $LOG/log.txt
SPENT=$(((`date +%s` – $START)/60))
echo “End: `date`”
echo “Duration: $SPENT minutes”
Note: The script will only work on the same device.