I have sql query which only count a particular rows.
I need to prepare a script which will run that sql query every 10 minutes and if the ouput count is greate than 20. It will send SMS to mobile numbers.
# Untested, since I've neither got Oracle nor an SMS gateway available
count=$( sqlplus -s user/pw@sid @count_script )
if [ $count -gt 20 ]
then
# Command to send SMS here
fi
Set up a cron job to run this every 10 minutes and that should do it.
for running at 10mins interval i will add it in crontab. Thats not a problem.
but just to need the script which will fetch the output and send sms. I will first try to save the output in log file. Please tell How to put date and time and append the output in one file" ??
#! /bin/ksh
su - oracle
count=$( sqlplus -s abc/abc@mydb @select count(*) from xyz.order where create_date < sysdate - 1/720; )
But output has error Syntax error: `(' is not expected.
how to fix?
Meanwhile in IF THEN statement I want to append output count in simple txt file. How to add?
if [ $count -gt 20 ]
then
# Coutput will be in txt file. And will append the output in same file
fi
---------- Post updated at 04:30 PM ---------- Previous update was at 03:16 PM ----------
Hi guys,
i do able to connect to oracle. Infact, i need to export env variable.