Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 01-31-2004, 07:46 AM   #1
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Rep: Reputation: 50
howto delete files via ftp from cron job ?


I use this command from cron job

15 4 * * * root tar Pcj /usr/local/httpd | ncftpput -c -u <your_username_on_remote_host> -p <your_pass_on_remote_host> <remote_host> <directory_on_remote_host>/save-`date +%Y.%m.%d-%H%M`.tar.bz2

to save daily via ftp the whole Web server data

it's working well. but now I have
a lot backup files !

how to use this and delete at the same time all old ones backup files ?

kind regards
Old 01-31-2004, 10:19 AM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
I'm using the find command to delete the backup files which have a modification time ( mtime ) greater than 90 days. Modification time in this case is when the file is created.
You may be able to change this to meet your needs.

filename=`date '+%m%d%y'`
tar -cvzf /mnt/backup/${filename}.tar.gz /home
#Delete old files with the following command
find /mnt/backup -type f -name '*.gz' -mtime +90 -exec rm {} \;
Old 01-31-2004, 06:49 PM   #3
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 50

I will try this...

kind regards


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
delete mails thru cron job massoo Linux - General 0 01-12-2005 02:19 AM
cron job to delete files based on attributes alpha21 Linux - General 3 11-09-2004 12:06 PM
cron job to send file via ftp every 1 hour mcalizo Linux - Newbie 1 07-14-2004 03:50 AM
Howto run a job on a fixed time with cron? Schmurff Linux - Newbie 1 04-02-2004 03:31 AM
Can I make a Cron job to synch/transfer a file from a folder to another FTP?... read efishta Linux - General 6 07-19-2003 10:03 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:51 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration