Shell Script Create List of Deleted Files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script Create List of Deleted Files
# 1  
Old 01-21-2009
Shell Script Create List of Deleted Files

Hi,

I want to put all the deleted files in a txt file. Because i want to backup my image server which has thousands of jpg images. I wrote a shell script which will copies images from image server to backup image server. I setup a cronjob which runs on every five minutes. & through timestamp it tooks last five minutes jpg images and copies to Backup Image Server.

Now the problem is that when any image (jpg) deleted from Original Image Server how can i took this to also delete that image from Backup Image Server.

So, in order to meet that i believe i will put all the deleted jpg names (file names) into a text file and use that file to delete images from Backup image server.

So, can any one please let me know the commands how can i put deleted *.jpg files into text file so i can this on Backup image server to delete images.

Or let me know any other solution ?

Regards,
Muhammad Irfan
# 2  
Old 01-21-2009
as an alternative, why don't you check if you can use rsync? to know more about rsync, check here
# 3  
Old 01-21-2009
Yogesh,

Thanks for your reply. we don't want to use rsync. It is much havier. Can u please let me know how to record names of deleted files in a text file ?

Regards,
Muhammad Irfan
# 4  
Old 01-21-2009
who deletes the files? and how?

if files are being deleted from an application / script, then before deleting them, you can add an entry in a file.
# 5  
Old 01-21-2009
Yogesh,

On image server files are stored in random order. These are user images which are saved by our paid clients through website. For example

root@linux/root/images} ls -la
root@linux/root/images} 12345.jpg
root@linux/root/images} 12346.jpg

If any user delete image from the application. The image also deleted from the image server (off course). Let suppose 12345.jpg & 12346.jpg was deleted. I want when those images deleted the name of those images (12345.jpg & 12346.jpg) shall stored in a file.txt.

So i can use that file.txt to delete those images from Backup Image Sever which are copied through Shell Script. When those images are deleted from Backup Image Server. Both Servers are Synchronized.

Which is the AIM of doing that. Looking forward to hear from you.

Regards,
Muhammad Irfan
# 6  
Old 01-21-2009
Hi! prior to any deletion, you can try getting all the list of files and redirect it to a text file, then after the deletion or at any given time you might want to get all the list of files again and pipe it to another text file and compare that with the older file using maybe diff.

To check for the files which are in jpg format you can use the find command.

Also, why don't you try d above suggestion of using rsync. Rsync would be the best thing for this situation.

Last edited by yongitz; 01-21-2009 at 06:42 AM..
# 7  
Old 01-21-2009
Bug

Thanks for your reply you.

Well this solution comes to my mind but again the problem i have around 10 subdirectories beneath in images directory. So this is little bit difficult to manage this. Still i think the best option is define user define function in shell script whenever any jpg file deletes it record the name of that jpg file in a txt file & then simple delete file from another server by using that file.

I done this in past through shell script but i forgot what commands i used. Can u let me know about my scenario how is that ?

Regards,
Muhammad Irfan
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create a list of files from alias by script

Actually I have many pictures with diferent name and size around 2000, I need generate a copy of them from one list of alias. The structure of the list is something like this: alias_list.txt <01>randomname.png<02> Randomname.png RandoMname.png RandOmname.png RandomnamE.png... (6 Replies)
Discussion started by: Tapiocapioca
6 Replies

2. UNIX for Beginners Questions & Answers

List Files being deleted in a shell script

Good evening, i need your help please I've got a file script thet deletes about half millions of files, and i want those files to be printed in a log file as an evidence those files were removed. #/bin/sh rm "/home/e-smith/files/users/bill/Maildir/cur/1392373930.28512.comp01:2,S" rm... (6 Replies)
Discussion started by: alexcol
6 Replies

3. UNIX for Advanced & Expert Users

How to list deleted files in UNIX?

Hi All, Its an interview question. I just want to know the answer of below question. 1) How to list deleted files in unix (13 Replies)
Discussion started by: pspriyanka
13 Replies

4. Shell Programming and Scripting

How to create or convert to pdf files from csv files using shell script?

Hi, Can anyone help me how to convert a .csv file to a .pdf file using shell script Thanks (2 Replies)
Discussion started by: ssk250
2 Replies

5. UNIX for Dummies Questions & Answers

Generate list of deleted files

I copied all JPEGs from my laptop to an external drive using find . -name "*.jpg" -exec cp '{}' ./media/Backup/pictures \; And then deleted all of them from my laptop. Now, I realize that I need the folder path of all the original JPEGs as the path has the important information. I dont... (1 Reply)
Discussion started by: eshwaconsulting
1 Replies

6. Shell Programming and Scripting

To Create shell script files from a shell script

Dear Unix and Linux users, Good evening to all. I'm new to this community and thank you for having an wonderful forum. Dear members i had to create almost some 300 shell script files for a particular task. I tried something like this.... #!usr/bin/sh fname=epdb_jobs for x in `cat $fname`... (3 Replies)
Discussion started by: NehaB
3 Replies

7. Shell Programming and Scripting

how to create the files dynamically in c shell script

how can i CREATE a txt file dynamically in c shell: for instance: #! /bin/csh for each i (*) cat>file$i.txt for each j do .... (1 Reply)
Discussion started by: jdsignature88
1 Replies

8. UNIX for Dummies Questions & Answers

Create a shell script for write files with 2 parameters

Hello, I'm a newbie in shell script. So, i would like to create a shell script which take 2 IN parameters (PARAM1 and PARAM2). This script need to create 2 files as : I need to create this file /etc/apache2/sites-available/PARAM2 : <VirtualHost *:80> DocumentRoot "/home/PARAM1/www"... (0 Replies)
Discussion started by: chatlumo
0 Replies

9. Shell Programming and Scripting

How To create Flat Files using Unix Shell Script?

Hi all, How to create Flat Files using Unix Shell Script. The Script is supposed to be sheduled to run at a particular time? Thanks in advance Appu (4 Replies)
Discussion started by: Aparna_k82
4 Replies
Login or Register to Ask a Question