Okay... I have been searching and searching to no avail on what I am specifically looking for but here goes
I have a log file (several log files in several locations) that I was to backup and then truncate because they get big fast and once a week I want to just click a bash script to do the above task
Say the log is in /home/widget/log/x.log
and I want to back it up to /home/logs/<log name with current date on it>.log
and then truncate the original x.log leaving the filename intact
I tried this for the truncate:
Code:
#!/bin/bash
cat /dev/null >| /home/widget/log/x.log
and that works just fine
I tried this for a backup of file:
Code:
#!/bin/bash
SRCD="/home/widget/log/x.log"
TGTD=" /home/logs/<log name with current date on it>.log
OF=.-$(date +%Y%m%d).tgz
tar -cZf $TGTD$OF $SRCD
and it creates a file in the desired dir but it is empty and I do not want a tar file I was the same file type it started as (but as I said this only creates an empty file and doesn't backup the original log file)
I am pretty new to linux and any help would be appreciated
A script that contained the back feature and the tuncate feature following would help me a lot. I have several different ones I need to just change the original log location and destination paths for and I will later set up my cron job to perform this automatically.
Thank you in advance for your help
P.S. I use CentOS 5.7