- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- two processes is accessing the same file and i los...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2001 03:22 AM
02-15-2001 03:22 AM
two processes is accessing the same file and i lose infos
hi to all,
i'm tryim=ng to send the stdout of a process to a file that periodically is accessed by another process ( command date to have a reference in the log file) that starts from cron. What is happening is that the date is lost because, for sure, there is not synchronization between two processes that is accessing the file.
How can i do to fixe the problem ?
Thanks
Federico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2001 04:11 AM
02-15-2001 04:11 AM
Re: two processes is accessing the same file and i lose infos
Since these are two different processes , one way of doing them is using a file ( could be just a 0 byte ) as a lock file .
Each time before they access the file they check for the existence of this lock file and if it exist then they sleep for
Once the process is done accessing the file it removes the lock file .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2001 04:26 AM
02-15-2001 04:26 AM
Re: two processes is accessing the same file and i lose infos
Another solution would be to have your first process talk to the second via a pipe.
The second process should simply read the pipe and, if there is any data waiting, add a timestamp and write to a log file.
Depending of the amount and type of data logged by the first process, the second one could even be a shell script.
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2001 04:45 AM
02-15-2001 04:45 AM
Re: two processes is accessing the same file and i lose infos
OK,
but what is the procedure?
Federico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2001 04:58 AM
02-15-2001 04:58 AM
Re: two processes is accessing the same file and i lose infos
Why don't you use logger and syslog.conf to create your own logfiles and write to them using the syslogd.
See the logger manpage for more info. A number of user definable syslog 'facilities' are available.
Bye,
Rik.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2001 05:00 AM
02-15-2001 05:00 AM
Re: two processes is accessing the same file and i lose infos
Here is a 'quick and dirty example to put you on the traks:
#!/usr/bin/sh
while true
do
read DATA
date >> logfile$$
print $DATA >> logfile$$
sleep 5
done
Adjust the sleep time to whatever value you find adequate.
Save this code into a script, make it executable and run it as:
your_prog | this_script &
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2001 05:02 AM
02-15-2001 05:02 AM
Re: two processes is accessing the same file and i lose infos
I've hit the return key too quickly...
I like Rik's suggestion ;-)
Best regards,
Dan