hoytech / vmtouch

Portable file system cache diagnostics and control
https://hoytech.com/vmtouch/
BSD 3-Clause "New" or "Revised" License
1.79k stars 210 forks source link

How to process one lock after each other? #87

Open mgutt opened 3 years ago

mgutt commented 3 years ago

The following command does not make sense, as the first execution leaves vmtouch open:

vmtouch -l /file1
vmtouch -l /file2
vmtouch -l /file3

So instead I need to use the daemon mode:

vmtouch -d -l /file1
vmtouch -d -l /file2
vmtouch -d -l /file3

But by that all daemons are executed parallel (which can overload the CPU). Is it possible to wait until one lock command has been finished, before starting the next one?

The following solution works, but adds much more sleep time as it would be necessary:

vmtouch -d -l /file1
sleep 60
vmtouch -d -l /file2
sleep 60
vmtouch -d -l /file3
hoytech commented 3 years ago

In this particular example could you not do:

vmtouch -l /file1 /file2 /file3

This will mlock() each file in sequence.

hoytech commented 3 years ago

Oh and by the way, you can background a process with "&" in your shell to avoid daemonizing. Daemonizing will actually put the daemon process into a separate session, which is often not what is desired:

vmtouch -l /file* &