进程管理
<h1>3.15 进程管理</h1>
<p>1.查看进程
</p>
<p>2.杀掉进程</p>
<pre><code># kill掉agent
#jps -m | grep flume | cut -c 9-15 | xargs kill -s 9
#ps -ef | grep flume | cut -c 9-15 | xargs kill -s 9</code></pre>
<p>3.进程守护</p>
<pre><code>#! /bin/sh
process_name='flume-yls-to-kafka.conf'
stop_process(){
pids=`ps -ef | grep ${process_name} | grep -v grep | awk '{print $2}'`
for pid in ${pids}
do
echo `date` &quot;停止进程:${pid}:&quot;${process_name}
kill -9 ${pid}
done
}
start_process(){
sh /apps/flume-1.6.0/flume-yls-start.sh
sleep 5
pids=`ps -ef | grep ${process_name} | grep -v grep | awk '{print $2}'`
for pid in ${pids}
do
echo `date` &quot;启动进程:${pid}:&quot;${process_name}
done
}</code></pre>
<h1>定时任务/root/crontab/crontab.conf</h1>
<pre><code>stop_process
sleep 5
start_process</code></pre>