bash scripting help
I have written a script to detect access.log.1.gz file in my log directory /var/log/squid/
the problem i am facing is that when i run this script the squid service stops. i think the reason for this is that the current file access.log.1 is in ram is being read. in my log directory i sometimes get access.log.1.gz, acess.log.2.gz and so on, can someone tell me a better way to do detect only the gz files which are rotated and move them to a desired directory without affecting the squid working thanks a lot the script is given below #!/bin/bash cd /var/log/squid YMD="`date +%d%b%y`" echo "------------------------------------------------" >> ~/squid_script/log echo -e "backup of squid logs on $YMD\n" >> ~/squid_script/log echo "------------------------------------------------" >> ~/squid_script/log for file in a*.gz do echo -e "renamed file $file to $file$YMD " >> ~/squid_script/log mv $file /media/backup/access/$file$YMD echo -e "file $file$YMD transfered to /media/backup/access/ \n" >> ~/squid_script/log done |
So just to confirm, you are saying that once the file has been zipped it is no longer in use?
|
yes once compressed then of no use to squid , i have to move it to another directory where i can analyze the logs
|
So does - ~/squid_script/log
Only contain "*gz" files? If so, I would be guessing, but it is perhaps stopping due to the zipping not being completed at time of transfer and hence it is actually still connected to squid who then loses connection and dies. The only test that springs to mind would be to test the size of the zipped file and once it has stopped growing then moving it. |
I think you are not following me.
~/squid_script/log it generates a log of the transfer ">>" redirects the output into the file called "log" the configuration file /etc/logrotate.conf generates the gz file once a week ie on sunday i run the above script at midnight on monday, so i dont think its the problem of compression after the access.log.1.gz is formed the system automatically creates a new access.log file i think that during the transfer this file too is read which causes the problem |
All times are GMT -5. The time now is 04:40 AM. |