Why Linux is not showing file in use ?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Why Linux is not showing file in use ?
# 1  
Old 09-27-2011
Why Linux is not showing file in use ?

Hi

i have written a infinite loop which writes to a file log.txt

while [ 1 ]
do
echo " file in use " >> log.txt
done

i have started this process in one terminal , from another terminal i issued cp command

cp log.txt log2.txt

i was expecting a File in use message but didnt ?

i have checked lines in log2 which is far less than log.txt which is still executing .....

Actually i want to write a backup script which takes backup of our env every day where some or the other files are being used by some process at any given time ....

so can i follow the cp ..? because it was coping even still the file was opened in write mode

or could any one suggest other methods for taking regular backups

any help is much appreciated !!!
# 2  
Old 09-27-2011
as far as i know many daemons using lock file to control their status ( running/stopped/killed )

you may create a lock file on the first line of your backup script so as far the lock file exists dont let your applications/daemons ... to touch your files in any way.
# 3  
Old 09-27-2011
With the script as you've given it, the file is only in use as long as it takes to write one line to it, as on each output redirection the shell opens the file, writes, and closes it immediately afterwards.
This User Gave Thanks to pludi For This Post:
# 4  
Old 09-28-2011
so i cannot use the tar or cp for backup , what can be followed for taking regular backup of system where it is in use ...
# 5  
Old 09-28-2011
are you trying to backup a full file system or just a set of files?

Are you wanting to do this by a cron job or will it be manually kicked off everytime you want it backing up?

Are you backing up to tape or just creating .bak files?

there are a few different commands you can use to back files up and they vary on what you should use for what your trying to do?
# 6  
Old 09-28-2011
my requirement is backing one of our directory( we created that directory , not system directory) which is under the root file system.

our application will be running 24x7 ,which access that directory for read/write/executing ... i want to achieve 2 things

1) get the list of files which are in use by application at a given time , i check fuser but could not get clearly

2) getting the full backup of the directory every day using cron , for this i have written a small shell script which has a set of commands to created a tar of a given directory but how to deal with the files which in use by the application at some time

thank you !!
# 7  
Old 09-28-2011
Quote:
Originally Posted by rakeshkumar
1) get the list of files which are in use by application at a given time , i check fuser but could not get clearly
use lsof -p YourApplicationPID to find which files are currently used by the application.

Quote:
Originally Posted by rakeshkumar
2) getting the full backup of the directory every day using cron , for this i have written a small shell script which has a set of commands to created a tar of a given directory but how to deal with the files which in use by the application at some time
you may use lsof here too , and exclude the files that currently opened in your application when backing up.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Not showing ifcfg eth0....redhat enterprise Linux 6.2

Hello, I'm using dell inspiron 14R laptop and I installed Redhat enterprise 6.2 on this. After successfully installation i did not found any network interface on this. when i'm trying to load/add qeth driver . The driver is not found showing this message. Bash: lsmod | grep qeth Bash:... (4 Replies)
Discussion started by: dearsumon
4 Replies

2. UNIX for Advanced & Expert Users

Showing "permission denied" when trying to login in - Montavista Linux

Hello friends, I have scratched my system and after that when I am trying to access the console via root login it's failing with an error message of "permission denied". I am able to access the other login, I am having only problem with root and some other user login. I am using an telnet... (7 Replies)
Discussion started by: sanoop
7 Replies

3. Linux

Showing "permission denied" when trying to login in - Montavista Linux

Hello friends, I have scratched my system and after that when I am trying to access the console via root login it's failing with an error message of "permission denied". I am able to access the other login, I am having only problem with root and some other user login. I am using an telnet... (2 Replies)
Discussion started by: sanoop
2 Replies

4. Shell Programming and Scripting

shell_script showing errors in the below mentioned script while executing in linux

code: IMAGE=$imgvalue; if then echo DO=ABC; elif then echo DO=ETC; elif then echo DO=XYZ; else echo "$imgvalue is unsupported"; exit 1; fi in above script IMAGE=1 , IMAGE=2, IMAGE=3 whatever may be the value i have assigned it's showing only DO=ABC other conditions... (7 Replies)
Discussion started by: saku
7 Replies

5. Red Hat

Disk usage showing 100% after deleting files also | Red Hat Linux 3.2.2-5

My Redhat Linux system is always showing 100& disk usage. I have removed almost all the files, but no use and I am always getting 100% disk usage.!! Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda2 36337384 36066352 0 100% / I can... (7 Replies)
Discussion started by: sanoop
7 Replies

6. Shell Programming and Scripting

Grep command showing wrong output in Linux

Hi All I am trying to run a script in linux wherein i have a command like this grep ^prmAttunityUser= djpHewr2XFMAttunitySetup_ae1_tmp djpHewr2XFMAttunitySetup_ae1_tmp is a temporary file in which the user value is stored but this command in the script returns me balnk value whereas it has a... (4 Replies)
Discussion started by: vee_789
4 Replies

7. UNIX for Dummies Questions & Answers

Linux server not showing the GCC

Hi How can gcc is missing in linux ?i think we dont need to install it separately , can anyone please clarify when i issue a gcc command my terminal displays "If 'gcc' is not a typo you can run the following command to lookup the package that contains the binary: ... (2 Replies)
Discussion started by: rakeshkumar
2 Replies

8. Shell Programming and Scripting

Showing the first 4 lines of a file?

Is there a way to show the first 4 lines of a file without using head -4? In sed would it be sed '1,4d' ? What if I just wanted to display the 2nd line ONLY? How could this be done with AWK?...correctly with SED? (6 Replies)
Discussion started by: puttster
6 Replies

9. AIX

not showing the year of file

Hi I am facing strange issue in one direcotry it is not showing year of file, can you please suggest me wheather there is any limitation on year, on some other file though it is showing the dates. Regards, Manoj. (1 Reply)
Discussion started by: manoj.solaris
1 Replies

10. UNIX for Advanced & Expert Users

fuser not showing file open by vi

hi, I opened a simple text file by vi. I then started another shell, and did fuser myFile. I expected it to show the pid of the vi session that had that file open, but it just returned a blank. why would this be? thanks (4 Replies)
Discussion started by: JamesByars
4 Replies
Login or Register to Ask a Question