I have a file on a Samba share and there are several computers which append data to the file. I need to lock this file by each computer in order to perform append operations sequentially. How can I achieve it?
The reason is that the file turns out complete mess at that moment. I've tried to play with Samba options but I couldn't solve this issue.
[global] netbios name = XXXXXXX server string = %h server (Samba, Ubuntu) map to guest = Bad User obey pam restrictions = Yes pam password change = Yes passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . unix password sync = Yes syslog = 0 log file = /var/log/samba/log.%m max log size = 1000 dns proxy = No usershare allow guests = Yes panic action = /usr/share/samba/panic-action %d idmap config * : backend = tdb [HwInfo] path = /home/XXXXXXXXX/hw/IN write list = all read only = No create mask = 0644 guest ok = Yes
I created the next script:
STR="\n\n\n$1\n\n" while : ; do echo -e $STR >> "./temp/info.csv" done
and ran it in the several terminal sessions on the same computer simultaneously. "./temp" is the mount point for the Samba share.