Find the answer to your Linux question:
Results 1 to 3 of 3
I'm trying to do a disk cleaning bash and I've run into some problems. I've installed CygWin to deal with this (server is running win2K3 server) What I'm actually doing ...
  1. #1
    Just Joined!
    Join Date
    Jul 2008
    Posts
    4

    Question mv command and creating a bash file

    I'm trying to do a disk cleaning bash and I've run into some problems.
    I've installed CygWin to deal with this (server is running win2K3 server)

    What I'm actually doing is trying to move files and folder from /ftp/download and ftp/upload to /ftpold/

    1. I want to move files and folders older then 15 days to ftpold
    Using: find . -ctime +15 -exec mv {} /ftpold/ \;

    It moves some files but not all, I'm not sure why really.
    I want it to move all files and folders but exclude the folder "Ghost_Images" and ALL it's content /ftp/download/. It must not be moved.

    2. After all files and folders are moved which are older then 15 days, scan "ftpold" and delete files and folders which is older then 90 days. So that will be -ctime +90 i presume?

    How do i then get this into a bash file and run it?

    I've been working on this for a couple of weeks but can't get it right. Is there someone who will help me out?

    Best Regards.

    Henrik

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117

    Approach problems like an attorney

    Hi.

    Welcome to the forums.

    This response is more on the order of meta-help as opposed to specific help.

    I suggest that in general you begin thinking like an attorney.

    First, there is evidence. Statements like:
    It moves some files but not all, I'm not sure why really.
    are not useful until you tell us what files didn't get moved -- provide the evidence. A listing with ls -l would be helpful, otherwise it's just hearsay, and people's memories are notoriously faulty.

    Secondly, there are theories. If you think that there may be some reason for a particular result, you need to investigate farther. That may mean doing small experiments to see how commands work in certain circumstances, with certain options, etc. My directories are filled with small scripts to see specifically what commands actually do.

    If you are not comfortable with many of the features of bash, you may need to spend some time with resources, such as http://www.tldp.org/LDP/abs/html/index.html It's a long article, so just become familiar with what it offers. You can look for specific items as the need arises. There are numerous examples there to explain the concepts. You might initially ask yourself: "can I write a Hello, world script?"; if not, you need to read some introductory material there, and develop your practice.

    Third, there is scene reconstruction. Setting up a model of what happened can be important, particularly for learning. The command touch, for example, can create files of specific ages in *nix (I don't know if it works like that in Cygwin -- an opportunity for you to experiment). If touch works, then you can create a script that will set up a model of your real problem. Then your solution script can be run against the test model again and again to learn what works and what doesn't. If you break your scene, simply re-run the reconstruction script.

    Appealing to the court. If you come up against a problem that doesn't seem to make sense, then by all means ask questions here, but remember to provide the evidence.

    The most successful attorneys (and people who use computers) are those who dig for answers for themselves, and are well-prepared.

    Like all clients, you are free to ignore this advice .

    See you in court ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Just Joined!
    Join Date
    Jul 2008
    Posts
    4
    Quote Originally Posted by drl View Post
    Hi.

    Welcome to the forums.

    This response is more on the order of meta-help as opposed to specific help.

    I suggest that in general you begin thinking like an attorney.

    First, there is evidence. Statements like: are not useful until you tell us what files didn't get moved -- provide the evidence. A listing with ls -l would be helpful, otherwise it's just hearsay, and people's memories are notoriously faulty.

    Secondly, there are theories. If you think that there may be some reason for a particular result, you need to investigate farther. That may mean doing small experiments to see how commands work in certain circumstances, with certain options, etc. My directories are filled with small scripts to see specifically what commands actually do.

    If you are not comfortable with many of the features of bash, you may need to spend some time with resources, such as http://www.tldp.org/LDP/abs/html/index.html It's a long article, so just become familiar with what it offers. You can look for specific items as the need arises. There are numerous examples there to explain the concepts. You might initially ask yourself: "can I write a Hello, world script?"; if not, you need to read some introductory material there, and develop your practice.

    Third, there is scene reconstruction. Setting up a model of what happened can be important, particularly for learning. The command touch, for example, can create files of specific ages in *nix (I don't know if it works like that in Cygwin -- an opportunity for you to experiment). If touch works, then you can create a script that will set up a model of your real problem. Then your solution script can be run against the test model again and again to learn what works and what doesn't. If you break your scene, simply re-run the reconstruction script.

    Appealing to the court. If you come up against a problem that doesn't seem to make sense, then by all means ask questions here, but remember to provide the evidence.

    The most successful attorneys (and people who use computers) are those who dig for answers for themselves, and are well-prepared.

    Like all clients, you are free to ignore this advice .

    See you in court ... cheers, drl

    The Ls -l listing showed that the folder looked exactly the same as after command was executed. However, i found out that -ctime only looks at modified date and note create date, this explains some problems ill have. Ill have a look at the links you provided, just needed a push in the right direction Thnx!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...