Hello,
I'm newbie on shell scripting. I'm writing very basic shell script see below
Code:
#!/bin/bash
#
#Ognoo=$(date)
# this is path of archive
mobile=/storage/shared/mobile
medium=/storage/shared/medium
# total size of files thats equal and older than 15 days
mosize=$(find $mobile -type f -exec ls -l {} \; | awk '{ s+=$5 } END { print s }')
mesize=$(find $medium -type f -exec ls -l {} \; | awk '{ s+=$5 } END { print s }')
# file count
mocount=$(find $mobile -type f | wc -l)
mecount=$(find $medium -type f | wc -l)
# mail related
# ipaddr=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
if [[ $mecount -gt 0 || $mocount -gt 0 ]]; then
find $medium -type f -exec rm {} \;
find $mobile -type f -exec rm {} \;
if [[ $mocount -eq 0 && $mecount -eq 0 ]]; then
echo "$(date) Successfully deleted" >> archive_deleter.log
echo "$(date) MEDIUMi size: $mesize number of files: $mecount MOBILE size: $mosize number of files: $mocount tus bur ustgalaa." | mail -s "Server: $ipaddr archive removed successfully" tseveendorj.o@localhost
else
echo "$(date) Error: file(s) => 15 days still has in these directories" >> archive_deleter.log
fi
else
echo "$(date) There has no files equal and older than 15 days" >> archive_deleter.log
fi
this file contains many echo commands but does not print on Terminal of Ubuntu. And also it did not send email. when I cat my postfix log from /var/log/mail.log no record. How do I fix this ?