1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【メモ】SQLの定期実行

Posted at

SQLを定期実行する。覚えられないためメモ。
環境:RHEL6.5
ORACLE:

1.SQLを定期的に等間隔で実行する

while true; do
echo "@select.sql"
sleep 5 ;
done | sqlplus / as sysasm

2.CronでSQL実行の予約

test.sh

#!/bin/bash -l
export ORACLE_SID=***
sqlplus / as sysdba @/home/oracle/test.sql

test.sql

spool /home/oracle/sysdate_test.txt app
select TO_CHAR(SYSDATE, 'YYYY/MM/DD HH24:MI:SS') from dual;
exit

クーロン登録(実行ユーザーでcrontab -e)

# m h day mon dow user  command
*/10 * * * * /home/oracle/test.sh 1>/dev/null 2>/dev/null

service crond status

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?