flock
{ flock -n 3 [ $? -eq 1 ] && echo "anoter prossess is running" && exit 1 sleep 10 echo helloworld11 sleep 3 echo helloworld22
} 3>/root/1.pid
shell的文件锁操作
原文:https://www.cnblogs.com/jkklearn/p/15144459.html