Pages

Monday, December 17, 2012

delete files older than x days linux



find . -name "*.trc" -mtime +35 -exec ls -lrt {} \; -- list
find . -name "*.trc" -mtime +35 -exec rm -rf  {} \; -- remove

---# above commands will find in current directory and
---# all sub directories for files older than 35 days, with .trc 


find /u01/ -name "*.log" -mtime +7 -exec ls -lrt {} \; --list
find /u01/ -name "*.log" -mtime +7 -exec rm -rf {} \; --remove

---# above commands will find in /u01/ directory and
---# all sub directories for files older than 7 days, with .log






Monday, December 3, 2012

Linux rsync, scp without password prompting



On source server:


[oracle@oradbpr] $ ls -rlt /home/oracle/.ssh/id_rsa.pub

if above file exists, copy id_rsa.pub to destination server, else generate with below ssh-keygen command.

[oracle@oradbpr] $ ssh-keygen -t rsa

Hit enter key, when prompted for passphrase.
private key and public key generated at /home/oracle/.ssh/id_rsa.pub
copy id_rsa.pub file to remote server.(destination server)

[oracle@oradbpr]$ scp /home/oracle/.ssh/id_rsa.pub oracle@oradbdr:/home/oracle
oracle@oradbdr's password:


On destination server:


[oracle@oradbdr] $ pwd
/home/oracle
[oracle@oradbdr] $ cat id_rsa.pub >> /home/oracle/.ssh/authorized_keys
[oracle@oradbdr] $ chmod 700 /home/oracle/.ssh/authorized_keys


On source server:


[oracle@oradbpr] $ rsync -avH /orabkp/ARC_PROD* oracle@oradbdr:/backup/archbkp

now rsync without password prompting.