瀏覽代碼

mautore to automatically restart things

master
mort 8 年之前
父節點
當前提交
529f8d72da
共有 1 個文件被更改,包括 24 次插入0 次删除
  1. 24
    0
      bin/mautore

+ 24
- 0
bin/mautore 查看文件

@@ -0,0 +1,24 @@
#!/bin/bash

DIR="."
CMD="$1"

$CMD &
PID=$!

OLD=$(ls -R --full-time "$DIR")

while :; do
NEW=$(ls -R --full-time "$DIR")
if [ "$OLD" != "$NEW" ]; then
OLD=$(ls -R --full-time "$DIR")

kill -9 "$PID" > /dev/null
[ $? != "0" ] && echo "Process $PID doesn't exist."

$CMD &
PID=$!
fi

sleep 1
done

Loading…
取消
儲存