Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to synchronize file I/O of many independent applications on Linux?

I'm writing a software for Linux which would actively work with user's files in background concurrently with other applications that I don't control. I want to make my background application to not overwrite changes made by other applications. But there is a problem - unlike Windows Linux doesn't provide mandatory file locking capability which creates possibility of ruining user's work due to race conditions which I'd like to avoid.

So I wonder - are there file-systems available on Linux that provide some kind of synchronization mechanisms such as compare-and-swap operation, all-or-nothing transactions, mandatory file locking (like in Windows)?

like image 849
Gill Bates Avatar asked Sep 20 '18 19:09

Gill Bates


People also ask

What is synchronized I O in Linux?

Synchronized I/O is useful when the integrity of data and files is critical to an application. Synchronized output assures that data that is written to a device is actually stored there. Synchronized input assures that data that is read from a device is a current image of data on that device.

How do I sync files between Linux servers?

Edit the crontab file by creating a cron job schedule for syncing your two Linux servers' directory files. Save and close the crontab file. The above-implemented cron job will automatically sync the backup/secondary server with the main/primary server after every 5 minutes.


1 Answers

Rename is atomic. It is up to your application to compare "eTags" of source and destination (possibly under appropriate locks) before deciding on calling rename().

like image 194
itisravi Avatar answered Oct 13 '22 06:10

itisravi