Hi all,
I have a folder that I am trying to tar ut is leading to unexpected results.
Ive written a script that find a certain number of files(logs) with specific names older than 14 days, moves them to a folder and compresses that folder.
_ARCHIVE=/opt/test/archived_logs
_DAILY=/opt/test/archived_logs/logs_$(date +"%Y_%m_%d")
cd $_BASE/$i/log
find $_BASE/$i/log \( -name "*out.*" -o -name "*log.*" -o -name "event-runtime-*" -o -name "event-[0-9]*" -o -name "upload-trace-*" -o -name "pmm-[0-9]*" \) -mtime +14 -exec mv {} $_DAILY \;
tar -zcvf $_DAILY.tar.gz $_DAILY
The find commands returns me a number of log files and places them into $_DAILY .
The problem that I am seeing is that when I untar the file created by the end, I have to go down further directories like:
[user@server archived_logs]$ ls -tlrh
total 12K
-rw-rw-r-- 1 user group 5.8K Apr 14 15:05 logs_2015_04_14.tar.gz
drwxrwxr-x 3 user group 4.0K Apr 14 15:55 opt
[user@server archived_logs]$ pwd
/opt/ericsson/archived_logs
[user@server archived_logs]$ cd opt/test/archived_logs/logs_2015_04_14
[user@server archived_logs]$ file opt/ericsson/archived_logs/logs_2015_04_14
opt/test/archived_logs/logs_2015_04_14: ASCII English text, with very long lines
how can I remove the path (opt/test/archived_logs) created ?
Secondly the initial folder contains a number of log files. But when I untar the file, I only have one file in it rather than a number of log files.
Any idea what I am doing wrong ?