Tuesday, 29 December 2015

Datewise File find Scripts


--------------------
Scripts Crontab
--------------------
00 04 4 * * /etc/monthly.sh
00 04 * * 2-6 /etc/scanlog.sh
00 05 * * 1 /etc/monday.sh

--------------------------------------------------------------------------------------------------
 Total Count Files on Monthly Basis with string Scripts with rename datewise
--------------------------------------------------------------------------------------------------

#!/bin/bash
rm -rf /home/Monthly.log
touch /home/Monthly.log
echo -------------- AB ------------ >> /home/Monthly.log
cd /home/ab/
echo "MONTHLY PDF: " $(find /home/ab/ -type f -name "*201511*.pdf" |wc -l) >> /home/Monthly.log
echo ------------------------------ >> /home/Monthly.log
printf "\n \n" >> /home/Monthly.log
sleep 10
echo ------------- CD ------------- >> /home/Monthly.log
echo "MONTHLY PDF: " $(find /home/cd/ -type f -name "*201511*.pdf" |wc -l) >> /home/Monthly.log
echo ------------------------------ >> /home/Monthly.log
printf "\n \n" >> /home/Monthly.log
sleep 10
cd /home/
DATE=$(date +"%Y%m%d%H%M")
mv Monthly.log Monthly$DATE.log
exit


------------------------------------------------------------------------------
 Daily basis DateWise  Total Dir/FIles/DateWise PDF Generate
------------------------------------------------------------------------------

#!/bin/bash
rm -rf /home/scanlog.log
touch /home/scanlog.log

echo -------------- AB------------ >> /home/scanlog.log
cd /home/ab/
echo "TOTAL DIR: " $(ls -l | grep ^d | wc -l) >> /home/scanlog.log
echo "TOTAL PDF: " $(find . -name "*.pdf" | wc -l) >> /home/scanlog.log
echo "TOTAL DATEWISE PDF: " $(ls -ltR  |grep  $(date --date="-1 days" +%Y%m%d.pdf) | wc -l) >> /home/scanlog.log
echo ------------------------------ >> /home/scanlog.log
printf "\n \n" >> /home/scanlog.log
echo ------------- CD ------------- >> /home/scanlog.log
cd ../cd/
echo "TOTAL DIR: " $(ls -l | grep ^d | wc -l) >> /home/scanlog.log
echo "TOTAL PDF: " $(find . -name "*.pdf" | wc -l) >> /home/scanlog.log
echo "TOTAL DATEWISE PDF: " $(ls -ltR  |grep  $(date --date="-1 days" +%Y%m%d.pdf) | wc -l) >> /home/scanlog.log
echo ------------------------------ >> /home/scanlog.log
printf "\n \n" >> /home/scanlog.log
cd /home/
DATE=$(date +"%Y%m%d%H%M")
mv scanlog.log scanlog$DATE.log
exit


-----------------------------------------
 This Script execute only Monday
-----------------------------------------

#!/bin/bash
rm -rf /home/Monday.log
touch /home/Monday.log
echo --------------AB ------------ >> /home/Monday.log
cd /home/ab/
echo "TOTAL DIR: " $(ls -l | grep ^d | wc -l) >> /home/Monday.log
echo "TOTAL PDF: " $(find . -name "*.pdf" | wc -l) >> /home/Monday.log
echo "TOTAL DATEWISE PDF: " $(ls -ltR  |grep  $(date --date="-2 days" +%Y%%m%d.pdf) | wc -l) >> /home/Monday.log
echo ------------------------------ >> /home/Monday.log
printf "\n \n" >> /home/Monday.log
echo ------------- CD ------------- >> /home/Monday.log
cd ../cd/
echo "TOTAL DIR: " $(ls -l | grep ^d | wc -l) >> /home/Monday.log
echo "TOTAL PDF: " $(find . -name "*.pdf" | wc -l) >> /home/Monday.log
echo "TOTAL DATEWISE PDF: " $(ls -ltR  |grep  $(date --date="-2 days" +%Y%m%d.pdf) | wc -l) >> /home/Monday.log
echo ------------------------------ >> /home/Monday.log
printf "\n \n" >> /home/Monday.log
cd /home/
DATE=$(date +"%Y%m%d%H%M")
mv Monday.log Monday$DATE.log
exit


No comments: