1) Bkup Tnsnames:
$ cp tnsnames.ora tnsnames.ora.date +"%Y%m%d%H%M"
-rw-r—–. 1 oracle oinstall 564 Oct 20 11:57 tnsnames.ora
-rw-r—–. 1 oracle oinstall 564 Nov 28 22:25 tnsnames.ora.201611282225
2) Crontab Backup :
$ crontab -l > crontab_orig_date '+%m%d_%H%M'
$ ls -ltr crontab*
-rw-r–r–. 1 oracle oinstall 2175 Nov 28 22:26 crontab_orig_1128_2226
3) Create copy of listener log with last N lines (for Troubleshooting)
tail -150 listener.log > listener_log_hostname
_date '+%m%d_%H%M'
.log
$ls -ltr
total 40716
-rw-r–r–. 1 grid oinstall 31183 Nov 28 22:29 listener_log_cloudserver1_1128_2229.log
-rw-r—–. 1 grid oinstall 3325292 Nov 28 22:29 listener.log
4) Suffix date for any OS command :
_hostname
_date '+%m%d_%H%M'
.log
5) Find files greater than 1 GB.
find . -size +1000000k
6) Find file
find . -name tnsnames.ora
7) Delete trace files greater than 30 Days:
### find . -name ‘*.trc’ -mtime +30 -exec rm {} \;
### find . -name ‘*.xml’ -mtime +30 -exec rm {} \;
8) Make file into null (Check the file name properly before making it null)
cp /dev/null <filename>
9) Find specific file from root
#find / -name init.ora 2> /dev/null
10) Checking telnet is working or not?
telnet <IP ADDRESS> 1521
11) Find String in Directory :
### grep -R ‘test’ /u01/app/oracle/dba
12) Find SQL Text for TOP Unix process from TOP Command:
prompt “Please Enter The UNIX Process ID”
set pagesize 50000
set linesize 30000
set long 500000
set head off
select
s.username su,
substr(sa.sql_text,1,540) txt
from v$process p,
v$session s,
v$sqlarea sa
where p.addr=s.paddr
and s.username is not null
and s.sql_address=sa.address(+)
and s.sql_hash_value=sa.hash_value(+)
and spid=&SPID;
13) grep -B3 ORA-04031 *alert* : View above 3 lines from the line of error message.
14) Copy directory from remote server to local server:
cd /backup
scp -pr oracle@remote_server:/backup/software /backup/
15) To restart job if it is not running in background use below command :
ps -ef | grep lag | grep -v grep || nohup /u01/app/oracle/dba/bin/lag.sh ORCL11 60 &
Note : Please test in your local unix machine before you try it in production.