0

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?

1
  • What is the question? Can not find any question mark in your text.
    – ceving
    Jun 3, 2011 at 19:20

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .