photon
9/25/2016 - 1:13 PM

a simple and ugly way to start and stop a process - 2. proc stop script

a simple and ugly way to start and stop a process - 2. proc stop script

#!/bin/sh

# A quick, dirty script for stoping a process  
# Works at least for bash 4.2.25(1)-release (x86_64-pc-linux-gnu)
# Don't forget to assign a proper previledge to this file
# Usage: proc_stop.sh
# proc_start.sh @ https://gist.github.com/photonxp/d61d9c00ae8aface4ab766caf3c45545

proc_name=proc.name
# get pid from tmp file
pid_path=/tmp/$proc_name.pid
pid=`cat $pid_path`

echo "killing $proc_name pid ..."
cmd="kill $pid"
$cmd
echo "$cmd"

cmd="rm $pid_path"
$cmd
echo $cmd
echo "Stop script is done ..."