KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Bash: Check up, Run a process if not running Hi , My requirement is that , if Memcache server is down for any reason in production , i want to restart it immediately Typically i will start Memcache server in this way with user as nobody with replication as shown below memcached -u nobody -l 192.168.1.1 -m 2076 -x 192.168.1.2 -v So for this i added a entry in crontab this way (crontab -e) */5 * * * * /home/memcached/memcached_autostart.sh memcached_autostart.sh #!/bin/bash ps -eaf | grep 11211 | grep memcached # if not found - equals to 1, start it if [ $? -eq 1 ] then memcached -u nobody -l 192.168.1.1 -m 2076 -x 192.168.1.2 -v else echo "eq 0 - memcache running - do nothing" fi My question is inside memcached_autostart.sh , for autorestarting the memcached server , is there any problem with the above script ?? Or If there is any better approach for achieving this (rather than using cron job ) Please share your experience .
Tags (comma-separated)
Save Edits
Cancel