Wednesday, May 18, 2016

how to mount the raw disks or nfs mounts that are listed in fstab

we can use this simple method to find what disks or mounts are missing before we bring the database up....

To understand this better.... initially the admins will put an entry in fstab for the disks and mounts that need to be mounted... but sometimes we dont see all disks come up.... it figure it out and make them available you can use this small script....

list=`awk '{print $2}' /etc/fstab |grep -i "/" | grep -v '^/etc/fstab' | grep -v '^/director' | grep -v '/abcdef_data' | egrep '/.'`         ----(you can exclude some more using grep -V)
for i in $list
do
grep -iw $i /proc/mounts > /dev/null
status=$?
if [ $status -eq 0 ]; then
echo " $i is mounted"
else
echo "$i is not mounted"                      ---------you can mount the missing one by adding (mount $i)                                                                      ... if you want it to mount directly)
fi
done

Tuesday, May 17, 2016

how to attach files to email in UNIX in shell scripts or command line

Use below command to send the files as attachment in Email. doing this also helps you to zip the files and email. also this reduces the email size too.
as we all know we send logfiles

Linux:-

echo body_text_you_want | mailx -a file_name.zip -s "Subject_line_you  want to specify" abcef@domain.com

for AIX:-

to attach a file

(echo "Subject:Test email\nTo:adbcef@domain.com\nFrom: adbcef@domain.com\n\nAttached log file";uuencode file_name file_name) |  /usr/sbin/sendmail abced@domain.com


to attach multiple files....

(echo "Subject:Test email\nTo:adbcef@domain.com\nFrom: adbcef@domain.com\n\nAttached log file";(uuencode file_name file_name; uuencode file_name_2 file_name_2)) |  /usr/sbin/sendmail abced@domain.com



Hope this helps.

PostgreSql: Useful Commands-

 1)   ************************* Users ***************************  -- List of users with roles assigned: SELECT usename AS role_name,   CASE...