OS Logs
[root@server ~]$ dmesg -wH
[root@server ~]$ cat /var/log/messages | grep -i error
[root@server ~]$ journalctl
[root@server ~]$ journalctl -b
[root@server ~]$ journalctl --since=yesterdey
[root@server ~]$ journalctl -u slapd
[root@server ~]$ journalctl -u slapd -o verbose
[root@server ~]$ journalctl _COMM=su
[root@server ~]$ journalctl _COMM=su -o verbose
Last boot date and time
[root@server ~]$ who -b
[root@server ~]$ last reboot | head -1
[root@server ~]$ last -x|grep shutdown | head -1
Know the reason of reboot
[root@server ~]$ egrep -i '(shut|reboot)' /var/log/messages > /var/log/reboots.log
[root@server ~]$ cat /var/log/reboots.log
Who and when connected to the server
[root@server ~]$ utmpdump /var/log/wtmp | cat
Clean without deletion
[root@server ~]$ echo "" >error_log
LogRotate, as root
[root@server ~]$ vi /etc/logrotate.d/oracle
Logs will rotate every day and old ones will be compressed. We will have 10 latest backups
/u01/app/oracle/diag/tnslsnr/server_name/listener/trace/listener.log {
missingok
daily
rotate 10
compress
create 644 oracle dba
}
Oracle Instance
[oracle@server ~]$ tail -1000f /u01/app/oracle/diag/rdbms/oradb/ORADB/trace/alert_ORADB.log
[oracle@server ~]$ tail -1000f /u01/oracle/database/11.2/diag/tnslsnr/ocp/listener/trace/listener.log
Log output with GREENword, REDword ang YELLOWword
[oracle@server ~]$ tail -f /path/to/log | perl -pe 's/GREENword/\e[1;32;40m$&\e[0m/g,s/REDword/\e[1;31;40m$&\e[0m/g,s/YELLOWword/\e[1;33;40m$&\e[0m/g'
Example of Oracle Alert Log
[oracle@server ~]$ tail -1000f /u01/app/oracle/diag/rdbms/oradb/ORADB1/trace/alert_ORADB1.log | perl -pe 's/GREENword/\e[1;32;40m$&\e[0m/g,s/Completed: /\e[1;32;40m$&\e[0m/g,s/Archived/\e[1;32;40m$&\e[0m/g,s/Flashback/\e[1;32;40m$&\e[0m/g,s/started/\e[1;32;40m$&\e[0m/g,s/Opened/\e[1;32;40m$&\e[0m/g,s/Database mounted/\e[1;32;40m$&\e[0m/g,s/Media Recovery Canceled/\e[1;32;40m$&\e[0m/g,s/YELLOWword/\e[1;33;40m$&\e[0m/g,s/starting/\e[1;33;40m$&\e[0m/g,s/ORA-/\e[1;33;40m$&\e[0m/g,s/ALTER/\e[1;33;40m$&\e[0m/g,s/Shutting/\e[1;33;40m$&\e[0m/g,s/Stopping/\e[1;33;40m$&\e[0m/g,s/stopped/\e[1;33;40m$&\e[0m/g,s/Archiving is disabled/\e[1;33;40m$&\e[0m/g,s/Starting/\e[1;33;40m$&\e[0m/g,s/Media Recovery Start/\e[1;33;40m$&\e[0m/g,s/REDword/\e[1;31;40m$&\e[0m/g,s/ORA-0/\e[1;31;40m$&\e[0m/g,s/ERROR/\e[1;31;40m$&\e[0m/g,s/error/\e[1;31;40m$&\e[0m/g,s/Errors/\e[1;31;40m$&\e[0m/g,s/failed/\e[1;31;40m$&\e[0m/g,s/Instance shutdown complete/\e[1;31;40m$&\e[0m/g,s/Drop/\e[1;31;40m$&\e[0m/g,s/Deleted/\e[1;31;40m$&\e[0m/g,s/Deadlock/\e[1;31;40m$&\e[0m/g,s/BLUEword/\e[1;36;40m$&\e[0m/g,s/Media Recovery Log/\e[1;36;40m$&\e[0m/g,s/Media Recovery Waiting for thread/\e[1;36;40m$&\e[0m/g'
Example of Oracle Listener Log
[oracle@server ~]$ tail -100f /u01/app/oracle/diag/tnslsnr/server_name/listener/trace/listener.log | perl -pe 's/GREENword/\e[1;32;40m$&\e[0m/g,s/REDword/\e[1;31;40m$&\e[0m/g,s/YELLOWword/\e[1;33;40m$&\e[0m/g'