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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Envinomental problem

Status
Not open for further replies.

Gloups

IS-IT--Management
Sep 16, 2003
394
FR
Hi all

I have to execute a script like this example:

for i in D*;
do
chmod 777 $i;
done

tar -cvf /test/tar/my_test_file.tar DOCT*
rm DCOT*

for i in D*;
do
tar -uvf /test/tar/my_test_file.tar $i;
rm $i
done


When this script is launched by tomcat following a user action on the web frontend, the tar starts an block after the 762th file included in the tar archive.

When i execute myself the script with the same user tomcat uses, the scipt complete with no errors.


Assuming the script is good, it should have an environmental difference in the scipt execution context but i cant find it.

I also changed ncargs parameter assuming my files names are long (42 chars) but the problem still remain.

Any idea will be appreciated
 
Hi,

If some named pipe is present in the directory at the time the script is started from the web then blocking is possible because tar process waits for the end of file from the pipe which will never arrive.

Add a test on the type of the file before updating the tar file

if [ ! -p $i ]
then
tar -uvf /test/tar/my_test_file.tar $i;
else
ls -l $i 1>/tmp/some_tar.log 2>&1
fi

Ali
 
i've tried to add your test but it doesn't seems to be a named pipe and the tar process always block at the 762th file.

I've also tried with gnu tar instead of the original Aix tar. In this case, the process block at the 1024th file.

Strange value isn't it ?
 
Hi,

Yes it is, but I think I've get it because I've meet something similar some months before:
tar is a long process compared to delete.
When taring small files, tar can go fast and delete does its job after the file is tared.
For big files, tar began its job and delete comes after before tar process is completed to read the file.

for i in D*;
do
tar -uvf /test/tar/my_test_file.tar $i && rm $i
done

this way, rm command is executed only when tar is completed and exit status is 0. If tar fails for some reason (exit code non 0) rm $i is not executed.

Ali



 
thank's but in my case tar doesn't fail, it stays in idle mode and never stop until i kill it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top