start a unix process if its no longer running

I have a process running on a unix machine (AIX) which stops or dies every 30 minutes or so
I need a shell script to keep monitoring the process and start it if the process is no longer running

the process is started using /opt/abc/bin/skc
process name is skc

Thanks
pegahelpdesk1Asked:
Who is Participating?
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.

sweetfa2Commented:
Predefined RMC Conditions Installed by Default

At install time, more than 80 different conditions are defined within RMC and are for use with the click of a mouse (or command-line interaction). In addition to the conditions, predefined responses are provided with the system to support general-purpose activities such as e-mailing root, broadcasting an event and so on. Of course, to do something more useful requires writing specific response scripts that perform the actions needed to recover from the trigger conditions. For example:

The file system grows too large--increase the file system size or archive the data.
A process stops running--recover the process or restart the application.
Service levels start to drop--modify the Workload Manager (WLM) configuration or perform a dynamic LPAR (DLPAR) operation.
A server fails--execute recovery and move the workload to a different server.

Do you have RMC available on your environment?  That would be the simple and AIX way to do things.
0
carlmdCommented:
Add the process to inittab file with the respawn option.

Check the man pages for inittab for the exact syntax.
0
skullnobrainsCommented:
if the above don't fit your needs, cron this

* * * * * pgrep skc || flock -w 60 /tmp/skc.lock /opt/abc/bin/skc

if you start it using cron, you can skip the "pgrep skc ||" part

this will restart the script instantaneously when it dies after having been restarted through cron but restart it at moast once per minute. you can change the numbers how you need

the init way seems better if available
0

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
Ernie GronblomCloud Systems EngineerCommented:
Fortunately there is a program that comes with every Unix system that does just that!  It is the init process and it will monitor any process it starts and can restart it if it should go away.

Add the following line to your /etc/inittab file:
skc:234:respawn:/opt/abc/bin/skc

Then, run 'init q' to have it start the process (make sure it isn't already running) or you can reboot your system and the process will start as soon as the run level gets to 2, 3, or 4.

Ernie
0
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
Shell Scripting

From novice to tech pro — start learning today.