Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Processes , one file - is this a problem?

Status
Not open for further replies.

jouell

MIS
Nov 19, 2002
304
US
Hi.

Setup:

OS:Linux FC4
Shell:bash 3.00

I am experimenting with having a script that fires off a bunch of processes (simple web server monitor) that all will append a line to the same file:


for each in $(cat $FILE); do

script.sh "$EACH" &

done
wait


Each script.sh will do the append. Will this be a problem if I am simply doing an append? Or am I going to need to do some sort of file locking? Unless I have more than 1 cpu, I don't see how more than one process will write an exactly the same instant.

I am open to suggetions

Thanks!
-John







 
Hi

As far as I know, [tt]bash[/tt] will ensure that the redirected outputs to a file will not mess up the things. ( Supposing that you write with [highlight #eeeeff][tt]echo "bla-bla" >> logfile[/tt][/highlight]. )

But for logging purposes you can use [tt]logger[/tt] :
man logger said:
NAME
logger - make entries in the system log

DESCRIPTION
Logger provides a shell command interface to the syslog(3) system log module.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top