Script to copy data from one directory to another and at the same time remove copied files after 30 days.

It is typical that we need to schedule (cron) operations on files for archiving or pre/post – processing purpose. Below script is and example, can be use to simplify with customization of your example:

#!/bin/bash

source_dir="11"
dest_dir="22"
log_file="log.txt"
now=$(date +%s)

echo "$now START Files to move from $source_dir to $dest_dir" >> $log_file
files_to_move=$(find $source_dir -type f)
echo $files_to_move >> $log_file
xargs -I{} -n 1 mv {} "$dest_dir" <<< $files_to_move
echo "$now END  move file" >> $log_file

echo "$now START Remove files older than 30 days" >> $log_file
remove_files=$(find $dest_dir -type f -mtime +30)
echo $remove_files >> $log_file
xargs -I{} rm {} <<< "$remove_files"
echo "$now END -- Remove files" >> $log_file
No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

VMware
VCF, backup configuration

Backup implementation for VMware component is fairly easy. Just the requirements is to configure SFTP server in proper way and make it network available to the VMware components. SDDC Manager and NSX Manager backup In VCF Operations it is possible to configure backup for SDDC Manager and NSX Manager. Go …

VMware
VCF Automation, fresh environment configuration with identity providers and access control.

Introduction Login Login as user admin to the Organization name: system or if selected manual: Check the connections (in Administration section), where you should see connection to the vCenter and NSX-t manager as those are provided automatically via VCF Operations: the same for VCF Instances: Also check your networking: Identity …

VMware
VCF SoS

SoS (Supportability and Serviceability) command can be used for troubleshooting purpose to generate VCF (per component) log bundle, massively enable/disable ssh service on ESXi, vCenter, password and certificates expiry status, verify cluster health and many other. while troubleshooting, the following commands can be helpful: