Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have to write a script for a CentOS server which will kill and restart a process every three days. After killing the process it needs to execute another script and start the killed process.

Unfortunately after two or three days this process stops working, perhaps related to a memory issue.

Any ideas?

share|improve this question
    
What is the question? Can not find any question mark in your text. –  ceving Jun 3 '11 at 19:20
add comment

1 Answer

up vote 0 down vote accepted

This question is confusing - do you want a script because you have to restart the process because it stops working after 2-3 days? And do you want to know why the process stops working? If so, it depends entirely on the process; what is the actual process? Nobody can tell you why a program stops working if they don't know what the program is!

If you just want an idea for a script, try this:

#!/bin/sh
program=/usr/local/bin/program
pidfile=/var/run/program.pid
kill -9 $pidfile
$program &
echo $! > $pidfile

and run it on a crontab of every three days:

0     0     1/3     *     *         /your/script

This isn't tested so please excuse the odd error, but you should see the general idea.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.