![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need shell script to get last 10 char from a file name and write in to a new file | raj0390 | Shell Programming and Scripting | 2 | 07-28-2008 04:09 AM |
| Need to write a script in UNIX to find a file if another file exists | mmdawg | Shell Programming and Scripting | 1 | 05-04-2008 07:40 PM |
| PHP Script that sends mail - Postfix breaks it | boopfm523 | Shell Programming and Scripting | 0 | 03-05-2008 08:38 PM |
| How to write a shell script to send an email to an id | madhumathikv | Shell Programming and Scripting | 4 | 10-23-2007 02:19 PM |
| Email message if file size > 0 bytes | poste_d_ordure | Shell Programming and Scripting | 1 | 06-02-2006 04:02 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
write the script to get the file size and sends an email
hi all
Anybody have an idea to write the script to get the file size and sends an email when file size increse more than 10mb. thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
/bin/find /path/tofile -name filename.whatever -size +10485760c > ./big.dat
if [[ -s ./big.dat ]] ; then
big.dat > /usr/bin/mailx -s 'file too big ' usename@foo.com
fi
|
|
#3
|
|||
|
|||
|
Thanks for your reply..
i have something which i didnt get.. /bin/find /path/tofile -name filename.whatever -size +10485760c > ./big.dat i have several files (*.txt) under the /var/opt/abc, then also is this command work? |
|
#4
|
|||
|
|||
|
Thanks for your reply..
i have something which i didnt get.. /bin/find /path/tofile -name filename.whatever -size +10485760c > ./big.dat i have several files (*.txt) under the /var/opt/abc, then also is this command work? what I'm looking for is, as i said i have serveral files (*.txt) under the /var/opt/abc. if any of the file increased to more than 1mb, then i wanna send a mail with increased file name and size. Thanks once again. |
|
#5
|
|||
|
|||
|
Yes,
/path/tofile => /var/opt/abc filename.whatever => "*.txt" |
|
#6
|
|||
|
|||
|
Thanks for your reply.
I just tried with the script which you give me and it did work with some changes. I modified the script like below find -name core.* -size +10485760c > ./big.txt #if [[ -s ./big.txt ]] ; then #big.txt > /usr/bin/mailx -s 'file too big ' abc@xyz.com this works but I want to see file size too like this.. -rw------- 1 root root 254517248 Aug 4 21:36 core.2909 and this line i wanna send as a mail. when I tried with this... /bin/find /path/tofile -name filename.whatever -size +10485760c > ./big.dat It says couldn't find the /bin/find. Thanks for your help. |
|
#7
|
||||
|
||||
|
try this....
ls -lrt|awk '$5 > 10485760 {print}' > ./big.txt if [[ -s ./big.txt ]] ; then /usr/bin/mailx -s 'file too big ' abc@xyz.com < big.txt Last edited by vidyadhar85; 08-12-2008 at 07:01 PM. |
||||
| Google The UNIX and Linux Forums |