Register a domain and help support LQ
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-25-2006, 11:52 PM   #1
Registered: Feb 2006
Location: Maine
Distribution: Ubuntu
Posts: 44

Rep: Reputation: 15
Help writing a shell script!

I need to write a shell script that determines what happens when the '>>' (append) operation accesses a file at the same time as another program. For example:

If two users logged on at the same time and a logfile was being written with the '>>' operation, does the file get accessed by both at the same time, therefore one is overwritten by the other becuase they were working on the same line, or does it wait?

I just need ideas for how to test this, not the actual answer. Thank you.
Old 04-25-2006, 11:56 PM   #2
Senior Member
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 61
Sure sounds like homework.
Old 04-25-2006, 11:57 PM   #3
Registered: Feb 2006
Location: Maine
Distribution: Ubuntu
Posts: 44

Original Poster
Rep: Reputation: 15
Haha...yes indeed, but I am lost as to how to do it. I understand the concept, but am not sure how to launch two processes at the same time.
Old 04-26-2006, 12:03 AM   #4
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
You could utilize the at deamon or even cron, but at would probably work better for you. Just add two jobs that write different output to the same file. By the system clock they will be simultaneous.


Old 04-26-2006, 12:30 AM   #5
Registered: Sep 2004
Location: Hyderabad
Posts: 440
Blog Entries: 1

Rep: Reputation: 30
i dont think that buffer for the both the instances at the same time. are u taking the log froma a single system?
Old 04-26-2006, 12:15 PM   #6
Senior Member
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,371

Rep: Reputation: 192Reputation: 192
open two xterms

and do
cat >> file

and what you type will go in the file.

find . >> file


Last edited by bigearsbilly; 04-26-2006 at 12:17 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
writing a shell script tchoua Linux - General 8 02-24-2005 07:18 PM
shell script writing ust Linux - General 6 01-24-2005 02:06 PM
writing my first shell script speedhead34 Linux - Newbie 4 12-20-2004 01:50 AM
help writing shell script np complete Linux - Newbie 6 08-30-2004 10:43 PM
Need Help in Writing a Shell Script. KptnKrill Linux - General 2 05-19-2003 06:44 AM

All times are GMT -5. The time now is 12:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration