Tuesday, May 17, 2016

Delete two hours old files in Sun OS


In Sun OS mmin doesnt work to delete the older files..

To delete older files on SunOS use "newer" option

oracle@sev2(1125) db2 /opt/app/db2/oracle/admin/db2/udump
$ date
Tue May 17 18:33:22 EDT 2016
oracle@sev2(1126) db2 /opt/app/db2/oracle/admin/db2/udump
$ touch 05171633 /tmp/TIMESTAMP 
[05=month 17 = date 1633 = 16:33 pm ( 2 hours older than current time)]
oracle@sev2(1128) db2 /opt/app/db2/oracle/admin/db2/udump
$ nohup find . ! -newer /tmp/TIMESTAMP -exec rm {} \;

Tuesday, May 10, 2016

Linux : how to mail all files under a directory

the below command can help sending all the files under a directory

cd /location/where/files/are/present/
for file in .* *; do mailx -s "${file}" -a "${file}" <email@id> < ${file}; done

FYI : each file will be sent as separate email.