Gnu – Flock

This is an interesting command. Have you ever wanted to be sure that just one instance of your app/script is running at the same time? Then, flock is your tool. The sintax is as follows:

flock [options] file|directory command [arguments]

Lets see an example:

flock /home/user/lockfile htop

This runs htop and uses a generated file in home/user named lockfile to control the locking. If you try to run the same command, you will not be able to run htop again until the first instance finish.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also enjoy…