# !/bin/bash
# set environment
export ORACLE_SID=xxx
export ORACLE_HOME=/path/to/oracle/home
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_LANG=American_America.AL32UTF8
CONN=user/password@$ORACLE_SID
LOG_FILE=/var/www/html/ora_sessions/print_ora_sessions.`date +%Y%m%d%H%M%S`.log
sqlplus -s $CONN >> $LOG_FILE <<EOF
set pages 10000
set lines 150
COLUMN sid FORMAT 99999
COLUMN machine FORMAT a20
COLUMN username FORMAT a20
COLUMN status FORMAT a10
COLUMN program FORMAT a50
ALTER SESSION SET nls_date_format='yyyy/mm/dd hh24:mi:ss';
SELECT sid,serial#,machine,program,username,logon_time,status
FROM v\$session
ORDER BY logon_time;
quit
EOF
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme