The updates made by background process are not lost, the question is what happens when you are about to do "save & quit" - you will be prompted with message that the original file has changed : do you want to save anyway ?
The other thing is when someone else is trying to vi the same file opened by you - he will get a message :
Quote:
E325: ATTENTION
Found a swap file by the name ".temp.txt.swp"
owned by: sysgate dated: Wed Apr 25 17:29:23 2007
file name: ~sysgate/temp.txt
modified: no
user name: sysgate host name: $myhost
process ID: 30240 (still running)
While opening file "temp.txt"
dated: Wed Apr 25 17:27:07 2007
(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r temp.txt"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".temp.txt.swp"
to avoid this message.
Percy, as sysgate noted, your solution will heavily depend on what exactly
you want to update in the file.
Is it really necessary to "vi" the file?
Could a shell be written to do the updates you want?
This is a big file, full of filenames and a hashcode for each filename.
each line in the file is
filename, date, hashcode
filename, date, hashcode
...
Anyway, so a file comes into a server, gets a hashcode which is then put into this big log file of mine, and then the file is processed.
Should the file be sent in again to the server, its hashcode is checked and if it exists (ie, my process has dealt with it already) it deals with the file appropriately.
I come unstuck when I need to reprocess the same file again - so I need to edit the large log file and remove the entry (the whole line - name,date,hashcode) so that I can feed it through again.
Write a sh to deal with this? - not sure - its one of those where it happens often, but not often enough to justify a sh....but its something I guess I could look into.
One other thing:
Suppose two people sudos to a user (the same user) first, and then edits the file - you don't get the message about the file changing when you save/quit right? - at least that's what it appears to happen over here in bizarro world...
Percy,
Here is one possible solution:
1) Rename the "work_file" to a "tmp_file" and immediately create a
new "work_file" so that new records can continue to be added to it.
2) "vi" the "tmp_file" and make all changes you want.
2.a) After you are finished with your changes on the "tmp_file",
do not quit yet.
2.b) Go to the end of the "tmp_file" and in the command line type:
This will read the "work_file" entirely and place it after the last line
of "tmp_file".
2.c) Write and quit the "tmp_file".
As you say the file is very large, if you try to save the work area
as "work_file", it may take a long time and use a lot of memory
and disk space.
3) Immediately rename "tmp_file" back to "work_file".
See if this could work for you.
There is still the slight potential of missing additions to the logfile between steps 2c and 3 - and its mainly due to how fast I can type "mv file file2" - in a panic, I probably spend more time hitting the backspace than actually typing commands correctly.
Its definitely a better catcher of entries than the solution I had in mind - so thanks very much!
I also want to point out that your question is not dumb at all, in my previous company we were 7 admins with root access + the process who was doing the updates of sensitive data files. There were moments that we had to edit the file manually, and, fortunately, we had the possibility to rewrite the deamon to accept responces that the files is inaccessible now, and batch the data for later insertion. That's why the question is not stupid, instead may turn into headache.
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi,
There are 2 users (T886072 & T864764) that need to be provided full (rwx) access to a directory. I made the changes to the directory permissions using chmod and setfacl :
root@digidb2:# chmod 700 /u02/ftpfiles/MFRS16/discount_rates/
root@digidb2:# setfacl -s... (3 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi all.
I have a .txt file that I need to sort it
My file is like:
1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO)
2- ... (10 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Is there a way to ignore a command within /etc/profile only when su'ing as any particular user.
For instance....
As root, if I run "su - oracle -c program" it is running a string in my profile called "echo "^2;$(hostname)-(ABC) @ $(who am i)^G".
I don't want the above string to run if I... (9 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)