/var/log/messagesに、"error hogehoge"と出力されたら、touchコマンドで"/tmp/hogedetayo"を作成します。 #!/bin/sh # 検出対象ログファイル TARGET_LOG="/var/log/messages" # 検出文字列 _error_conditions="error hogehoge" # ログファイルを監視する関数 hit_action() { while read i do echo $i | grep -q "${_error_conditions}" if [ $? = "0" ];then # アクション touch /tmp/hogedetayo fi done } # main if [ ! -f ${TARGET_LOG} ]; then touch ${TARGET_LOG} fi tail -n 0 --fo