![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| change wc -l | francis_tom | Shell Programming and Scripting | 1 | 04-14-2008 10:02 AM |
| change 43% to 43.5 | nortypig | Shell Programming and Scripting | 2 | 08-20-2006 12:55 AM |
| Want to change my Name | Awadhesh | Post Here to Contact Site Administrators and Moderators | 2 | 10-04-2005 05:54 AM |
| UID Change | mcateriny | AIX | 4 | 10-06-2003 09:02 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Change FileHandle
Hello,
I currently have a system that is running and writing to a log file. Every month I run a rollLogs script that moves this file to a different location and creates a new file in the original location. The service that is writing to this log is running when i run this script and it still has its FileHandle pointing to the old file. The program continues to write to the moved file instead of the new file. Is there a way to redirect the output of a file to the newly created log file without having to restart the program? Thanks for the help Andy |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
dup2()
See the dup2() manpage...assuming it's a C program
Code:
dup2(fd_of_new_file, fd_of_old_file); |
|
#3
|
|||
|
|||
|
Thanks for the response shamrock. I looked into it but was still unable to get this working. Im using PERL and the POSIX module has a dup2() that is suppose to mimic the c function.
Is there any easy way to determine the File Desc of the old log file? I was hoping i could just enter the path of the oldfile and the path of the new and the function would take care of the rest. Thanks again for the help |
|
#4
|
|||
|
|||
|
I think you can do your job in another way.
Copy old file to a new location, after that empty the original file. But there are chances of data loss, if the service writes log between copying and emptying. Last edited by mika; 07-09-2008 at 07:15 AM. |
|||
| Google The UNIX and Linux Forums |