1. Run flock -x /var/lock/lockdev/.1730576435.8206FEBB.0 sleep 30
The call will be blocked until /var/lock/lockdev/.1730576435.8206FEBB.0 is unlocked by another process, then lock the file 30 seconds, 30 seconds later, the call returns ;
If the file is not locked by any processes, the call will lock the file 30 seconds, 30 seconds later, the call returns ;
2. Run flock -x -w 3 /var/lock/lockdev/.1730576435.8206FEBB.0 echo "successful"
if the file /var/lock/lockdev/.1730576435.8206FEBB.0 is not locked by other process, "success" will be displayed soon and then the call returns;
If the file /var/lock/lockdev/.1730576435.8206FEBB.0 is locked by another process, the call will wait 3 seconds, if the other process still does not unlock the file, the call will return, and no message will be displayed.