![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Prevent users logging in as root | Sepia | SUN Solaris | 3 | 06-05-2008 10:45 AM |
| Multiple Sessions with FTAM | gauravgoel | UNIX for Advanced & Expert Users | 0 | 03-14-2008 01:37 AM |
| Users Are Getting Kicked out of 2Hr Sessions | Sarccastik Dude | AIX | 2 | 07-23-2007 07:07 PM |
| Prevent file from being mailed multiple times from a job | Sree_2503 | Shell Programming and Scripting | 2 | 11-14-2006 09:47 AM |
| How to prevent root users from editing files (logs) | vehchi | UNIX for Dummies Questions & Answers | 4 | 12-06-2005 03:29 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Locking a file when using VI to prevent multiple-edit sessions by diff users
At the office, we often have to edit one file with VI. We are 4-6 workers doing it and sometimes can be done at the same time.
We have found a problem and want to prevent it with a file lock. Is it possible and how ? problem : Worker-a starts edit VI session on File-A at 1PM Worker-b starts edit VI session on File-A at 1:05PM worker-a changes 100 lines and exit/saves at 2:00PM worker-b changes 1 line and exit/saves at 2:15PM as result, changes done by worker-a are lost we even had cases where losts of lines being edited were lost. if we could lock the file upon editing it with VI, it woud prevent others from editing it and would have to wait for whomever is in to finish before being able to edit it. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
not really a convenient solution ...
I would do that the hard way ... recompile from the source
Get the source, modify so to open in read-only mode (and warn user) if the lock file is present! Not really what you're looking for i guess |
|
#3
|
|||
|
|||
|
instant messaging, send a message to all other users that you are hacking around in the file so the others know to hold off until you are done.
i cannot think of an easy way with file locking to prevent your problem. we have several dev boxes that we modify or reboot at random and we use instant messaging to broadcast a message that we are doing some changes, seems to work for us. |
|
#4
|
|||
|
|||
|
locking via shell script ?
Isn't there a unix (AIX) command that can lock or unlock a file ?
That way we could simply execute a small script that would do : if file not locked lock file vi file unlock file else echo "file being edited" |
|
#5
|
|||
|
|||
|
A revision management system such as CVS and Subversion will eliminate all of your worries in the long run.
Do not let everybody modify the production version. Have every staff checkout a local copy, which everyone modifies on their own, commit to CVS, and at last only update the production version by the administrator after the current version has been considered okay. Best of all, such systems can help you keep the revision history of every file managed, so you literally never lose anything! |
|
#6
|
|||
|
|||
|
Maybe you can either:
1. ask the user to do a ps -ef before editing the file cerntst1:/# ps -ef | grep test root 478570 611346 0 15:29:18 pts/2 0:00 vi test.txt <----- root 647012 51760 0 15:29:39 pts/3 0:00 grep test or 2. create a program to detect the vi process and if vi test.txt is showing up in the process, exit. |
|
#7
|
|||
|
|||
|
Like cbkihong said, revision control is the way to go. You could even use a built-in system like rcs.
|
|||
| Google The UNIX and Linux Forums |