Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Need a shell script to find 0 byte files in 5 servers Post 302913676 by bakunin on Tuesday 19th of August 2014 07:44:21 AM
Old 08-19-2014
Quote:
Originally Posted by ChandruBala73
I have toatally 5 unix servers in which many applications are working

I need to set a trap to identify 0 byte files if any are created proactively.

For example:

Code:
find /apps/fresco/ -mtime 1 -size 0c -print >> zerobytefile.log

this command will find zero byte file for last 1 day (no need to check entire directory every day and this is for /apps/fresco folder which will cover all the interfaces and will apply for all my servers)

2) then filter this log file for any data and if any data is present then raise a trap.
First off: welcome to the forum and i hope you enjoy the ride. Please do us (and yourself) a favour and use as little text markup as possible. For any code, terminal output or similar data use "CODE"-tags, which let stand out yor text nicely. I have taken the liberty and replaced this in the quoted text above. Compare yourself. Thanks for your consideration.

To your problem: you alread constructed a command to identify such files. Instead of the ">>" operator you used you should use ">" to create this file anew every day. Establish passwordless login through ssh for some user (likely root, but any other user with sufficient rights will do) at each of the target machines. Put this command into a loop on any system, like this (only a sketch):

Code:
# cat list_of_hosts_to_monitor
hostA
hostB
hostC
hostD

# cat mymonitoring.sh
#! /bin/ksh

typeset fHosts="/path/to/list_of_hosts_to_monitor"
typeset fOut="/path/to/output/dir"
typeset chUser="root"          # or something else
typeset chHost=""

while read chHost ; do
     ssh -o 'BatchMode = yes' "${chUser}@${chHost}" "find /apps/fresco/ -mtime 1 -size 0c -print" > "${fOut}/${chHost}.log"
done < "${fHosts}"

exit 0

This gives you a file for each host (named like the hostname+".log") locally (in the directory $fOut points to) which you can examine separately.

Then set up a cron job to run this script daily.

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to find files

I have a directory which contains files with different kinds of extensions .everyday a file with .log gets added to it .i want to extract the file with .log extension which is created with todays date . thanks in advance (2 Replies)
Discussion started by: naren_samba2005
2 Replies

2. Filesystems, Disks and Memory

shell script to find zero byte files

I have a directory MYDIR In which i have several directories 1,2,3,4.... Now, In each of these directories i have several files a.dat, b.dat, c.dat, d.dat..... MYDIR ----1 ---------a.dat ---------b.dat ---------c.dat ---------d.dat ----2 ---------a.dat ---------b.dat ---------c.dat... (2 Replies)
Discussion started by: ramky79
2 Replies

3. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies

4. Shell Programming and Scripting

Shell script to find files

Hi Experts, I am trying to write a shell script that should 1. Find files with name (ab030.txt,Ab030.TXT,AB030.TXT,ab030.TXT,AB030.txt) 2. If any of the above found, rename it to AB030.TXT Thanks. (4 Replies)
Discussion started by: welldone
4 Replies

5. Shell Programming and Scripting

Shell Script - find, recursively, all files that are duplicated

Hi. I have a problem that i can't seem to resolve. I need to create a script that list all the files, that are found recursively, with the same name. For example if a file exists in more than one directory with the same name it list all the files that he founds with all the info. Could someone... (5 Replies)
Discussion started by: KitFisto
5 Replies

6. Shell Programming and Scripting

shell script to take input from a text file and perform check on each servers and copy files

HI all, I want to script where all the server names will be in a text file like server1 server2 server3 . and the script should take servernames from a text file and perform copy of files if the files are not present on those servers.after which it should take next servername till the end of... (0 Replies)
Discussion started by: joseph.dmello
0 Replies

7. Shell Programming and Scripting

Shell script to find filesystem capacity on 50 servers

Hi all, I am new to Unix and I want to write a shell script in a jumpbox for finding the filesystem capacity on 50 unix servers ( by ssh ) and then email the result in HTML format with server name and capacity % to a specific outlook distribution list. any suggestion would be of great help. (17 Replies)
Discussion started by: amitbisht9
17 Replies

8. Shell Programming and Scripting

Shell Script to delete files from 5 different servers

Hello, I'm new to shell scripting and need a quick note on how to write a shell script to perform deletion of files from 5 different hostnames in various locations. Found out to delete files from one path by using below command and made it to work on cron job but need to do it in a shell... (2 Replies)
Discussion started by: Teja G
2 Replies

9. Shell Programming and Scripting

Shell script for connecting multiple servers and then copying 30 days old files

Shell script for connecting multiple servers and then copying 30 days old files from those server . HI , I have 6 multiple servers pla1,pla2,pla3,pla4,pla5,pla6 1. These six servers have common shared mount point /var/share 2. Running script from /var/share to connect these servers.I... (1 Reply)
Discussion started by: rcroyal88
1 Replies

10. UNIX for Beginners Questions & Answers

Find and removing the old files and zipping the files using shell script

Hi, I am trying to removing the old files which were older than 10 days and same g zipping the files using the shell script. script was return as follows. find /jboss7_homes/JBOSS7/SKYLIV??/SKYLIV??_CRM/jboss-eap-7.0/standalone/log -mtime +10 -type f | xargs rm -f find /cer_skyliv??/log... (6 Replies)
Discussion started by: venkat918
6 Replies
MAKEDEV(8)						      System Manager's Manual							MAKEDEV(8)

NAME
MAKEDEV - makes system special files SYNOPSIS
/dev/MAKEDEV [argument] [device-name?...] DESCRIPTION
The MAKEDEV shell script is normally used to install special files. It resides in the /dev directory, the normal location of special files. Arguments to MAKEDEV are usually of the form device-name? where device-name is one of the supported devices listed in Section 7 of the Reference Pages and ? is a logical unit number. The argument operand is one of the following special arguments that create assorted col- lections of devices: Creates all standard device files for all systems. Standard devices for Alpha systems (in the order they are created) are as follows: klog, kcon, kbinlog, kmem, mem, null, vmzcore, console, ws0, mouse0, keyboard0, tty, pty0, pty1, ptmx, cam, audit, prf, pfcntr, zero, snmpinfo, lockdev, and sysdev0. Creates a set of 16 LAT device special files, one for each LAT terminal device. The n specifies the set option. The set option range is 0 to 38. Specifying lat38 creates 12 LAT device special files. Creates groups of pseudoterminal device special files, as follows: Cre- ates pty0 to pty22. Creates pty23 to pty45. Creates pty46 to pty56. Creates pty57 to pty64. Creates pty65 to pty72. Creates pty73 to pty80. Creates pty81 to pty88. Creates pty89 to pty96. Creates pty97 to pty101. The # specifies the group of pseudoterminal device special files created. Creates a group of packet filter device special files, as follows: Creates pfilt0 to pfilt63. Creates pfilt0 to pfilt63. Creates pfilt0 to pfilt127. Creates pfilt0 to pfilt255. Creates pfilt0 to pfilt511. Creates pfilt0 to pfilt1023. Creates pfilt0 to pfilt2047. Creates pfilt0 to pfilt3071. Creates pfilt0 to pfilt4095. The # specifies the number of ppacket filter device special files created. Creates those devices specific to the local site. This request causes the shell file /dev/MAKEDEV.local to be executed. This file must exist prior to using the local argument. Site spe- cific commands, such as those used to setup dialup lines as ttyd? and to create device special files for all non-Compaq devices, should be included in this file. Because all devices are created using mknod(8) this shell script is useful only to the superuser. NOTES
The MAKEDEV script installs files in the current working directory. Although device special files can be located anywhere on the system, they are usually created in the /dev directory, since this is where most applications expect to find them. Refer to the dsfmgr(8) reference page for information on the Device Special File Manager program. ERRORS
Either self-explanatory, or generated by one of the programs called from the script. Use sh -x MAKEDEV in case of trouble. SEE ALSO
Commands: config(8), dsfmgr(8), mknod(8) Interfaces: intro(7), packetfilter(7), pty(7) MAKEDEV(8)
All times are GMT -4. The time now is 04:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy