I've started to get some problems with corrupt gzip files. I'm not sure exactly when it happens and the colleague how set our storage have quit etc. so I'm not an expert in cron jobs etc. but this is how it looks today:
/var/spool/new_files/*.csv
{
daily
rotate 12
missingok
notifempty
delaycompress
compress
sharedscripts
postrotate
service capture_data restart >/dev/null 2>&1 || true
endscript
}
In principle at midnight the script restart all csv files in var/spool/new_files/
, change the name to them (increment them by 1) and gzip the one which is then named "2" and moves that to our long time storage.
I don't know if the files are corrupt just after they have been gzip or if this happens during the "transfer" to the storage. If I run zcat file_name | tail
I get an invalid compressed data--length error
. This error happens randomly 1-3 times per month.
So the first thing I want to do is to run gzip -k
and keep the original,
- Check if the files are corrupt after they have been gziped
- Retry once
- If this also fails add an error in logs
- Stop the cron job
- If the gzip file is ok after creation move it to long time storage
- Test if they are ok, if not:
- Retry once
- If this also fails add an error in logs
- Stop the cron job
- Throw away the original file
Does the logic that I suggest make sense? Any suggestions how to add it to the cron job?