LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Remove old folders scheduly (https://www.linuxquestions.org/questions/linux-newbie-8/remove-old-folders-scheduly-4175549038/)

l0pht 07-27-2015 05:26 AM

Remove old folders scheduly
 
in order, I want to remove old folders via timestamp in ftp, found this script :

Code:

    #!/bin/bash
# Shell script to remove whole (nuke) ftp directory structure 
# See url for more info:
# http://www.cyberciti.biz/tips/how-to-nuke-a-ftp-server.html
# -----------------------------------------------
# Copyright (c) 2006 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# NOTE: Requires ncftp/ncftlls ftp clients/commands
# =========================================================================
# Ftp server settings

### change me ###############################
# ftp login user
FUSER='---'FUSER='example'

# ftp password
FPASSWD='password'

# ftp server ip/name
FTPS='----='-----'

# ftp dirs to nuke Separate multiple dirs using
# a blank/white space i.e. /dir1 /dir2)
FTPDIRS='/dir1 /dir2'
##############################################
for d in $FTPDIRS
do
 subdires="$(ncftpls -u $FUSER -p $FPASSWD  ftp://${FTPS}/${d}/)"
 for dir in $subdires
 do
 rdir="${d}/${dir}"
ncftp -u"$FUSER" -p"$FPASSWD" $FTPS<<EOF
 cd $rdir
 rm *
 rmdir $rdir
 quit
 EOF
  done
 done
 # end of script

but it doesn't check the time. is there any script to remove folders by days?
thanks

HMW 07-27-2015 05:56 AM

I think that is going to be tricky using ftp. Sorting the files depends on the ftp server, and that can vary.

If you have ssh access, it would be easy, but I guess that is not the case.

See here for more info:
http://stackoverflow.com/questions/1...ftp-and-window
http://stackoverflow.com/questions/1...te-through-php

Best regards,
HMW

l0pht 07-27-2015 07:51 AM

Thanks
but no i want sort and remove these via ftp.
thanka


All times are GMT -5. The time now is 01:45 AM.