Visit Our UNIX and Linux User Community

Backup of today's file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Backup of today's file
# 1  
Old 02-08-2008
Backup of today's file


Here is the part o fmy script-
for file in $FileList
                if [[ $(ls -l $file 2>/dev/null) = *$today* ]];
                        echo "Skips $file file. It is todays file"
                        if [[ $isBackup -eq 1 ]];then
                            cp $file $BackupLocation 2>/dev/null
                            cat /dev/null >$file

                if [[ $isBackUp -eq 1 ]]
                        mv $file $BackupLocation 2>/dev/null
                        #cat /dev/null > $file
                        rm $file $BackupLocation 2>/dev/null
                        #cat /dev/null >$file

The problem exists in the today's file,i need to take the backup of the today's file also and then make the content 0 of that file,but what i have writen is not doing so,can you guys give me some suggestion how i can do that.I need a quick response guys,stucked in between.If you have any doubt regarding the question then let me know i will try to clarify it.


Last edited by namishtiwari; 02-08-2008 at 08:02 AM..
# 2  
Old 02-09-2008
What does "make the content 0" of a file mean?
echo 0 > $file
is what occurs to me, but I think it's unlikely that you want to to that.
# 3  
Old 02-14-2008
Originally Posted by Perderabo
What does "make the content 0" of a file mean?
echo 0 > $file
is what occurs to me, but I think it's unlikely that you want to to that.
The content of the file need to be 0 because today's file can grow up to a very large size,we need not to delete the file, because the server will pick these files and then again start writing in them,(if we delete the files then we need to start and stop the server again n again)files can be made 0 with this

cat /dev/null >$file
or >$file

this is done through a cron job.
# 4  
Old 02-14-2008
Originally Posted by Perderabo
What does "make the content 0" of a file mean?
echo 0 > $file
is what occurs to me, but I think it's unlikely that you want to to that.
Perhaps he wants to empty the file. Smilie

Previous Thread | Next Thread
Test Your Knowledge in Computers #990
Difficulty: Medium
UNIX System V is one of the first commercial versions of the Unix operating system and was originally developed by AT&T and first released in 1981.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find and copy .zip file based on today's date

Hi Team, I'm new to unix and i have a requirement to copy or move files from one directory to another based on current date mentioned in the .zip file name. Note that i need to copy only the recent zip file. please help me with the code i tried the code as: #! /usr/bin/sh find... (3 Replies)
Discussion started by: midhun3108
3 Replies

2. Shell Programming and Scripting

Help Needed for creating the folder by checking today's date and, take backup using rsync command

How to create a shell script to create a folder by using the today's date to take backup using rsync command on every evening around 7 pm. Kindly help. Thanks. To be more precise, I want to create a script which matches the today's date with server's date format, if matches then creates the... (2 Replies)
Discussion started by: bakula10
2 Replies

3. UNIX for Advanced & Expert Users

Script to rename file that was generated today and which starts with date

hello, can someone please suggest a script to rename a file that was generated today and filename that being generated daily starts with date, its a xml file. here is example. # find . -type f -mtime -1 ./20130529_4995733057260357019.xml # this finename should be renamed to this format.... (6 Replies)
Discussion started by: bobby320
6 Replies

4. Shell Programming and Scripting

meaning of today=${1:-${today}}

what does today=${1:-${today}} mean??? I saw a script which has these two lines: today=`date '+%y%m%d'` today=${1:-${today}} but both gives the same value for $today user:/export/home/user>today=`date '+%y%m%d'` user:/export/home/user>echo $today 120326... (2 Replies)
Discussion started by: Vidhyaprakash
2 Replies

5. Shell Programming and Scripting

getting timestamp of a file and if it was accessed today then finding a line in it

i have my files and the variables value extracted from db is taken as in1=slot0312 in2=best in3=it is :veryliong/fine as varibles.. i have a folder stuctures in my unix machine as : /2011/hand_sl0312/best/HOD/file1.txt /2011/hand_sl0312/happy/HOD/file1.txt... (1 Reply)
Discussion started by: rajniman
1 Replies

6. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

7. Shell Programming and Scripting

check file exists and created today issue

Morning My other issue I have seems very simple but im just not seeing it. I have a script that checks on a remote share to see if the backups for some systems have run. Its as simple as: find /mnt/ukwcs-net-config/WLAN-Controllers/ -mtime -1 -ls | egrep '(cfg)' > wlanlog.txt cut -c 1-92... (4 Replies)
Discussion started by: ltodd2
4 Replies

8. UNIX for Advanced & Expert Users

backup a file and keep every version of the backup

I am trying to backup my .bash_history and I want to keep every version of the backup. I am thinking to put one of these in my crontab. 0 0 * * 0,3 cat .bash_history > boo 0 0 * * 0,3 cp .bash_history boo I would like the backups to be called boo1, boo2, boo3, etc. I would like to keep... (7 Replies)
Discussion started by: cokedude
7 Replies

9. Shell Programming and Scripting

Files with 0 file size and created today

hi, I am building a script to identify those files created/modified today and with file size 0. I am able to find the files with 0 file size and created/modified in last 24 hrs as shown below but not today (current date), I tried using (touch -t time filenm) but in my version of unix at work it... (7 Replies)
Discussion started by: rushs682
7 Replies

10. UNIX for Dummies Questions & Answers

Check backup file size on backup tape

Hi, I performed backup on tape and I want to append more files to my previous backup on the same backup tape. But before I do that I need to know the backup file size of the first backup I performed so that I know the available size on the backup tape. Can someone help me what command I will use... (0 Replies)
Discussion started by: ayhanne
0 Replies

Featured Tech Videos