File related commands

1) find text in the matching files and show the filename with the pattern. The below example shows the list of filenames and the location of the hostname in those files, which will be helpful when changing hostnames for your websphere installation.

find . -name ‘*.xml’ -print | xargs grep ‘hostName’ /dev/null

bash-2.05b# find /usr/IBM/WebSphere/AppServer/profiles/AppSrv01/config/ -name ‘server*.xml’ -print | xargs grep ‘hostName’ /dev/null | more
/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells/portalserverCell01/nodes/portalserverNode01/serverindex.xml:<SERVERINDEX:ServerIndex xmi:version=”2.0″ xmlns:xmi=”” xmlns:serverindex=”
.0/serverindex.xmi” xmi:id=”ServerIndex_1″ hostName=”” endPointRefs=”NamedEndPoint_1130375480667 NamedE
ndPoint_1130375480668 NamedEndPoint_1130375480669 NamedEndPoint_1130375480670 NamedEndPoint_1130375480671 NamedEndPoint_113037548067

2) Soemtimes you might run out of diskspace and want to clean up some files, so this command will help you find all large files. In this example it will list all the files greater than 10 mb in size.

find / -xdev -size +1024 -exec ls -al {} \; | sort -r -k 5

bash-2.05b# find /usr/IBM/WebSphere -xdev -size +1024 -exec ls -al {} \; | sort -r -k 5-rw-r–r–
1 root root 1047553 Oct 26 2005 /usr/IBM/WebSphere/AppServer/profiles/AppSrv01/tranlog/n2110indch2Cell01/n2110indch2Node01/n2110indch2_server1/transaction/tranlog/log1
-rw-r–r– 1 root root 1047553 Oct 26 2005 /usr/IBM/WebSphere/AppServer/profiles/AppSrv01/tranlog/n2110indch2Cell01/n2110indch2Node01/n2110indch2_server1/transaction/partnerlog/log2
-rw-r–r– 1 root root 1047553 Oct 26 2005 /usr/IBM/WebSphere/AppServer/profiles/AppSrv01/tranlog/n2110indch2Cell01/n2110indch2Node01/n2110indch2_server1/transaction/partnerlog/log1

3) When sending SystemOut.log or SystemErr.log or trace.log to your developers or to IBM support Please use Tar and gzip on the fly to reduce the size of the file and the transfer time to FTP,email or http upload.

To pack on the fly…
tar -cvf – FILE-LIST | gzip -c > FILE.tar.gz

To unpack on the fly..
gunzip < FILE.tar.gz | tar -xvf –

To pack on the fly and email the file to IBM Support
tar -cvf – SystemOut.log | gzip -c | uuencode SystemOut.tar.gz | mail -s “PMR 09921,227,000” -b “SystemOut.log for server crash ”

To find selective files and tar it up on the fly…
find /opt/IBM/WebSphere/PortalServer/log -name ‘System*.log’| xargs tar -rvf System_logs.tar

4) Sometimes you might encounter a situation for example when running xmlaccess or wsadmin where you might want to write stdout to the file as well as to the console so that you have a copy even when the standard output disappears because of the screen buffer size.

ls -l | tee > filename -in ExportRelease.xml -username wpsadmin -password wpsadmin -url http://localhost:9080/wps/config | tee filename
./ | tee wsadmin.log

5) find files that is recently updated which might be useful to see what changes are made to the system recently (e.g) below command shows the files that are modified within the last 20 minutes(-mmin) and 20 days (-mtime)

find /usr/IBM -mmin -20
find /usr/IBM -mtime -20


6) Find a memory usage of the system.

cat /proc/meminfo

bash-2.05b# free
total used free shared buffers cached
Mem: 11819592 4938416 6881176 0 298148 1440200
-/+ buffers/cache: 3200068 8619524
Swap: 2048276 0 2048276

bash-2.05b# cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 12103262208 5056954368 7046307840 0 305303552 1474797568
Swap: 2097434624 0 2097434624
MemTotal: 11819592 kB
MemFree: 6881160 kB
MemShared: 0 kB
Buffers: 298148 kB
Cached: 1440232 kB
SwapCached: 0 kB
Active: 3718616 kB
ActiveAnon: 2968776 kB
ActiveCache: 749840 kB
Inact_dirty: 789328 kB
Inact_laundry: 237596 kB
Inact_clean: 0 kB
Inact_target: 949108 kB
HighTotal: 11140992 kB
HighFree: 6681628 kB
LowTotal: 678600 kB
LowFree: 199532 kB
SwapTotal: 2048276 kB
SwapFree: 2048276 kB
Committed_AS: 6039100 kB
HugePages_Total: 0
HugePages_Free: 0
Hugepagesize: 2048 kB

Yorum yapın?