YOu can check the process state table with grep on the name of the process you wished to check. ps -ef | grep “debu” > maillist.txt if [ -s maillist.txt ] ; then echo “Process is Running ” else cat maillist.txt | mailx -s “ALARM !!” abc@aol.com fi
to determine wether a process is running or not
#!/bin/sh var1=`ps -ef | grep -v grep | grep process_name| awk ‘{print $2}’` echo $var1 if [ -n $var1 ] then echo “The Process is Running” else echo “The process is not running” fi
Check if program is running with bash shell script?
This is an example of a bash script which checks for some running process (daemon or service) and does specific actions (reload, sends mail) if there is no such process running. check_process(){ # check the args if [ “$1” = “” ]; then return 0 fi #PROCESS_NUM => get the process number regarding the given Full Article…
ps -ef | grep to check if process is running
The script. #! /bin/sh #check the processes and email me if nsexpress is not running if ps -ef | grep “ns-httpd -d /usr/netscape/suitespot/https-lls/config” then echo “nsexpress is running” |mail george.rajapaksa at lls.edu else #echo “nsexpress is not running ” |mail george.rajapaksa at lls.edu cd /usr/netscape/suitespot/https-lls;./start fi The Problem: if pgrep -f “ns-httpd -d /usr/netscape/suitespot/https-lls/config” pgrep Full Article…
Remove grep from grep output of ps command
You might always see the “grep” as the list of processes when you grep for a particluar process. $ ps -ef | grep xscreensaver jsaikia 4050 1 0 May14 ? 00:00:00 xscreensaver -nosplash jsaikia 14282 14245 0 16:54 pts/2 00:00:00 grep xscreensaver If you want not to print it the output, you can do “grep Full Article…
How can I kill all processes from a certain user ?
ps -ax | grep <username> ps -ef | grep -v grep | grep sandipan ps displays the process table. efww is a group of options which affect how the process table is displayed. Read about them in the man page. | causes the standard output stream of ps to be piped into the following command’s Full Article…
4 Ways to Kill a Process – kill, killall, pkill, xkill
Kill command is use to send signal to a process or to kill a process. We typically use kill -SIGNAL PID, where you know the PID of the process. There are other ways to effectively kill a process — killing a process by name, killing a process by specifying part of the name, killing a process by Full Article…
Pkill.sh [Shell script to kill process by name]
In *nix the “kill” command needs to know the pid(process id) of the process to kill it. So i decided to code a bash script to kill a process by name : #!/bin/bash if [ $1 -eq “”]; then echo “Usage : ./pkill.sh <process name>” else get_proc=`ps -e -o pid,command | grep $1` echo $get_proc Full Article…