How to Force a File Handle to Point to a New File?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to Force a File Handle to Point to a New File?
# 1  
Old 04-12-2016
How to Force a File Handle to Point to a New File?

My developer delivered a program which creates a time-stamped logfile and the only way the logfile rolls is with the size parameter in the log4j file. The user wants to be able to roll the logs manually at the end of the day or shift or when a particular event occurs. I tried to manipulate the /proc/<pid>/fd/<fd> link to point to a fresh logfile, but the system won't allow it. Are there any other tricks or ideas (short of killing the process and restarting) that will allow me to terminate writing to the current file and start writing to a new file. Thanks in advance
# 2  
Old 04-12-2016
You can't force a running program to flush its internal buffers, close a file, and open a new file unless the code for that program was written with code to make that happen. Some system monitoring programs are designed to rotate log files when they receive a certain signal. The documentation for your system monitoring program should describe any such mechanism it provides. If your developer didn't provide such a mechanism and you need it to satisfy your users, file an enhancement request.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Force ssl/ssh to use the hosts file

does anyone know how to force ssh/ssl to use the hosts file instead of DNS? I have disabled the DNS servers but ssh still will not resolve a host in the hosts file. thanks in advance for the help! DS (3 Replies)
Discussion started by: derrell simpson
3 Replies

2. Shell Programming and Scripting

Grepping from a point in a file to the end of the file

does any one know how to turn the equivalent of this command: awk '/2011 John Doe 8344/,0' /tmp/ops.log | egrep -c "received request" to something that would use egrep instead of awk? What the awk command does is, it searches the ops.log file for "2011 John Doe 8344". When it finds it,... (4 Replies)
Discussion started by: SkySmart
4 Replies

3. Shell Programming and Scripting

How to force csh to not use floating point?

Hi, I'm using csh, grep, and awk to sum up the third field from a file. Unfortunately, this results in a very large number and csh creates a floating point value such as 3.11745e+06. I was hoping to get 3117450. I get this error when I run this portion of the csh script and I suspect the... (5 Replies)
Discussion started by: daffy
5 Replies

4. Solaris

Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command. I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file. Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies

5. Shell Programming and Scripting

handle file by month

Hi, I want to write a shell script which handle an oracle alert log so that when it changes month, the script generates a new file with month in the filename. Thanks in advance. Leim (4 Replies)
Discussion started by: leim
4 Replies

6. UNIX for Dummies Questions & Answers

How to change the file modification time of a file on nfs mount point

Hi I am accessing a file on nfs mounted device, after completing using of the file, i am tring to restore the access time and modification times of the file. So i got the previous modified time of the file using stat() function and trying to set the date and time for the file, To set these... (6 Replies)
Discussion started by: deepthi.s
6 Replies

7. Shell Programming and Scripting

How to handle multiple rows in a file

I have a FILE a.txt which has the following data 113901.94,113901.94,56950.97,56950.97,NOT MATCHING,NOT MATCHING 10693.04,10693.04,5346.52,5346.52,NOT MATCHING,NOT MATCHING 1901.94,1901.94,550.97,550.97,NOT MATCHING,NOT MATCHING 103.04,103.04,53.52,53.52,NOT MATCHING,NOT MATCHING #### This... (2 Replies)
Discussion started by: ksmbabu
2 Replies

8. Programming

deleting a file name by its handle

All, I am having three function 1.open 2.process 3.close. Open will open a file and process will process a file and close will close the file .. I can able to close the file by its filehandler.Is there is anyway that i can get the file name by filehandle and remove it after... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies

9. UNIX for Advanced & Expert Users

Stale NFS file handle

Hi, I get an error saying "Stale NFS file handle" how can I solve this? Is it possible to do this with a umount/ mount command? (5 Replies)
Discussion started by: rein
5 Replies

10. UNIX for Advanced & Expert Users

NFS file handle

How can I kill mount connection(NFS , made by automount) if remote filesystem is down? I tried: fuser -ku /auto /auto: umount /auto nfs umount: ERROR: /auto is busy If I try cd /auto - I get - /auto: Stale remote file handle. I know that reboot will help but I cannot reboot this... (2 Replies)
Discussion started by: kazimir
2 Replies
Login or Register to Ask a Question