Monitor Process and restart if not Running
I'm pretty new to linux - and my scripting is useless...
I have multiple processes that run.. but they are the same process, but with different configuration files. ./iroffer name.config (its an XDCC bot)... I've googled and read several scripts that monitor a process then restart it if its crashed, but I can't relate it to what i need... because i need the config file specific to the one that crashed. I will eventually have maybe up to 10 of these processes running with different name.config parameters (name being the bot name).. This is very similar to the eggdrop cron job.. but that was way to confusing for me.. Can anyone help me? I'm thinking cron job entry is what is needed.. run every 15 - 30 minutes maybe.. but the scripting is beyond me anyone familiar with what I need? |
When a command fails, the shell returns a non-zero error code. So if you were to type this on the command line:
Code:
ps ax | grep "iroffer name.config" | grep -v grep Code:
#!/bin/sh Make as many of those as you need for however many different variations of iroffer you have running. Also, test to make sure grep returns the correct matches. I am just assuming it would work in my example. Hope that helps or at least gets you started. |
Thanks - I'll give that a try with some testing
|
well. now I feel kinda foolish - after like a week of trying to find a script.. i found out the program comes with a cron job to enter already :)
i enter this on crontab -e */5 * * * * /home/username/iroffer/filename.cron so it runs every file minutes and it checks if the pid is stale or not.. and restarts it if it is.. So.. now my question - if i had 10 bots.. and this was running every five minutes x 10 times - could this impact performance on a dual core server with 2 GB of ram? this is the script Quote:
|
All times are GMT -5. The time now is 04:31 PM. |