#!/bin/sh
{
flock -n 3
[ $? -eq 1 ] && { echo fail; exit; }
echo $$
sleep 10
} 3>mylockfile
转载于:https://blog.51cto.com/biott/1095077