Creating a script to check the listener

I need to create a script to check the listener (lsnrctl?) on the database every morning for AM checks, I have no experience scripting and am new to Oracle. Can you give me some direction or instructions? Thanks
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
I assume you want to check for actual database connectivity not just the listener is up.

lsnrctl status will tell you if the listener is up.

tnsping DBALIAS will tell you that the listener is up and listening for DBALIAS but not if DBALIAS is up and running.

Anyway, you can do "lsnrctl status | grep"  for what you need.

I'm thinking you actually want to connect to the database and do something like "select sysdate from dual" for verify the database is up and responding.

Please clairify.

A quick Google will also likely provide you with these scripts or ones similar enough that you can tweak.  They are pretty common.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
basically, the command to query the status of the Oracle listener is
lsnrctl status
which you could of course use in a script.
An easier way might be using the tnsping utility which tries to reach the listener over the network.
The problem is that both tools only check the reachability of the listener, and don't test for the DB to be up and running.
So, if you really need to test the listener only, this might do the trick -

tnsping [servicename]
if [ $? -ne 0 ]
    echo Listener for [servicename] is not active!
Replace [servicename] with your proper value.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.