« Back to profile of grandi

  • Bash/shell

    التأكد من اشتغال برنامج ما check if a program is running

    بسم الله الرحمن الرحيم يمكنك هذا السكريبت من معرفة حالة برنامج ما، هل هو مشتغل أم تم قتله.. يمكن استعمال هذا السكريبت للتأكد تلقائيا من اشتغال برنامج ما، وإعادة تشغيله.. عليك فقط إضافته في crontab لتكون عملية المراقبة دورية. يمكن أيضا استعماله لمنع اقلاع متعدد لبرنامج ما ملاحظة: يجب القيام باختبارات متعددة أو اختيار المتغير APP بدقة لتفادي تضارب في الأسماء With this script you can check if a program is running or no, you can use this script to automate the process of checking the execution of a program and re-executing it. all you have to do is add it to crontab. you can also use it to prevent multiple execution of a program remark: you should do multiple tests or choose precisely the variable $APP in order to avoid inconsistency.

    12:48 Aug 23 2010 | Tags : bash,ps,grep,crontab,
    						APP='minbar' 
if ps -axl | grep -v grep | grep $APP > /dev/null
then
    echo "$APP is OK"
    #commands in this case
else
    echo "$APP is down"
    #commands in this case
fi    			         
Owned Code : anyexample.com
Add comment
To add a comment, please : Login or Sign up
    grandi
    خالد
  • New visitor?

    On setCode, you can save your codes, functions and classes, you can also share them with your friends, and track your favorite developer

    Join the SetCode community
  • Your language here :