一本完整的描述Unix Shell 编程的工具书的所有范例

源代码在线查看: kill-process.sh

软件大小: 1148 K
上传用户: buptbaishikele
关键词: Shell Unix 编程 范例
下载地址: 免注册下载 普通下载 VIP

相关代码

				#!/bin/bash				# kill-process.sh								NOPROCESS=2								process=xxxyyyzzz  # Use nonexistent process.				# For demo purposes only...				# ... don't want to actually kill any actual process with this script.				#				# If, for example, you wanted to use this script to logoff the Internet,				#     process=pppd								t=`pidof $process`       # Find pid (process id) of $process.				# The pid is needed by 'kill' (can't 'kill' by program name).								if [ -z "$t" ]           # If process not present, 'pidof' returns null.				then				  echo "Process $process was not running."				  echo "Nothing killed."				  exit $NOPROCESS				fi  								kill $t                  # May need 'kill -9' for stubborn process.								# Need a check here to see if process allowed itself to be killed.				# Perhaps another " t=`pidof $process` " or ...												# This entire script could be replaced by				#    kill $(pidof -x process_name)				# but it would not be as instructive.								exit 0							

相关资源