Check and Start the Service Script
Saw Khaing
Contributor
1 min read
Check the service count is greater than zero. if yes the service is running and if not start the service.
Code:
#!/bin/bash service=service_that_you_when_to_check
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 )) then echo "$service is running!!!" else /bin/systemctl start $service fi
Let’s put it in the one minute crontab to work automatically.
Code:
* * * * * /bin/sh /PATH/TO/SCRIPT.sh
Related posts
libvirt error in GNS3 @Linux
virbr0 is missing. You need to install libvirt ကျွန်တော်တို့တွေ Linux OS တွေမှာ GNS3 ကို install လုပ်ရင် တက်တတ်တဲ့ Error ထဲက တစ်ခုဖြစ်တဲ့ virbr0 is missing. You need to install…
1 min read
What is Software Define Networking – Part1 (Install OpenDayLight on Ubuntu)
ဒီနေ့ တွေးမိတာလေးရှိတယ်ဗျာ့ ခုဆို ကိုဗစ်နဲ့..မို့ အိမ်မှာနေရင်းနဲ့ Challenge လေးတွေလုပ်နေတာကို မြင်တော့ .. အိမ်မှာနေရင် ကမ္ဘာကြီးကို ကယ်တင်နေတဲ့ ညီ/ညီမတွေ skillတိုးဖို့ WFH…
5 min read
Cisco Tips & Trick – Part 1 ( Enabling linux shell command on cisco devices )
ဒီနေ့ ပြောပြချင်တဲ့ အကြောင်းအရာလေးကတော့ Cisco Device တွေမှာ Linux shell script တွေကို ဘယ်လိုဖန်တီးမလဲ Linux command တွေကို ဘယ်လို enable လုပ်ရမလဲ ဆိုတာကို ရှင်းပြပေးမှာပဲ…
3 min read



