This is a discussion on shell script to start a service within the Shell scripting forums, part of the Development/Scripting category; Hi. I need a script which could start squid automatically if it stops. I've added squid into rc.local but sometimes ...
|
|||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
|||
|
Hi.
I need a script which could start squid automatically if it stops. I've added squid into rc.local but sometimes when i start my machine it does not start automatically, can anyone help to write a script which could check if squid has started then it would not start again and if squid has not been started then it would start automatically.. Regards Asim |
| Sponsored Links | ||
|
|
|
|||
|
If you want to script this yourself you could check the PID file Squid uses when it runs, check if it exists and if it does cat it and save the PID to a variable. Then notice the full commandline Squid runs as, use that in pgrep -f 'commandline' and save the PID(
to an array. Check if the array is empty ("${#array[@]}"), else compare PIDs. If empty or PIDs not matching up, stop Squid gracefully, remove the PID file then start Squid.OTOH running a dedicated process watcher like Monit is easy to configure and expand, faster in checking and more versatile as it can start, restart about any service and alert you all in one go and all of the time. |
|
|||
|
Dear would you please write a simple script in the form of that you've above described so that it would be easy for me to proceed next and then i could be able to provide all the things those are required to make this script. Kindly help me.
Regards Asim |
![]() |
| Bookmarks |
| Tags |
| chkconfig , linux , redhat , runlevel |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| start service permanently in debian | myfoot | Ubuntu / Debian | 2 | 06-13-2008 01:16 PM |
| writing a shell script to find out my shell name | jaymob123 | Shell scripting | 1 | 10-08-2007 12:36 AM |
| start and stop service in crontab. | gthian | Shell scripting | 7 | 05-31-2007 11:04 AM |
| Redhat Enterprise Linux RHEL - Start service on boot | chimu | Getting started tutorials | 0 | 01-26-2007 07:29 PM |
| start up and stop the running script | mala_un | Shell scripting | 9 | 07-26-2006 07:10 AM |