Forum Stats

  • 3,728,472 Users
  • 2,245,631 Discussions
  • 7,853,549 Comments

Discussions

Directory got deleted ==

User_2WGON
User_2WGON Member Posts: 86 Red Ribbon

Hello all,

One of my colleague manage to run the following command under the directory "/u02/app/oracle/audit/" and what we found the entire Oracle directory got deleted which had all the binaries. Here , I am not sure if following command can cause this to happen since the command trying to search audit files which is older then 30 days and deleting only those files which met the criteria.

nohup find . "*.aud*" -mtime +30 -exec rm -rf {} \; &


Regards

Answers

  • User_T7ZSY
    User_T7ZSY Member Posts: 1 Employee
    edited April 27

    The command isn't searching for audit files. It is searching for files older than 30 days. The binaries are more likely older than 30 days.

    The correct command should be:

    nohup find . -name "*.aud*" -type f -mtime +30 -exec rm -f {} \; &

  • User_2WGON
    User_2WGON Member Posts: 86 Red Ribbon

    Thanks for your help here. Here , I would like to know the reason of folder getting deleted and also why it would not consider only deleteing the files which has .aud extension.

  • EdStevens
    EdStevens Member Posts: 28,049 Gold Crown

    I would like to know the reason of folder getting deleted and also why it would not consider only deleteing the files which has .aud extension.

    Because you failed to use the -name flag

    If it deleted all the oracle binaries, then I doubt you were in '/u02/app/oracle/audit/'. More likely in $ORACLE_HOME

  • User_2WGON
    User_2WGON Member Posts: 86 Red Ribbon

    Thanks Steve for your comment .. So if I were in under /u02/app/oracle/audit/ then it would have not deleted the entire directory correct with my version of command.


    Regards

  • EdStevens
    EdStevens Member Posts: 28,049 Gold Crown

    So if I were in under /u02/app/oracle/audit/ then it would have not deleted the entire directory correct with my version of command.

    You can see exactly what will be deleted, by issueing the command without the -exec. Instead of

    find . "*.aud*" -mtime +30 -exec rm -rf {} \;
    

    just use

    find . "*.aud*" -mtime +30
    

    Whatever is returned from that is what will be deleted when you add the '-exec rm -rf {} \;' And just to avoid any nasty surprises, I never run a 'find' with the '-exec' flag without first running it without, just to make sure it it hitting exactly what I want.

    And even for the full operation, there is nothing to be gained by running it with nohup.

Sign In or Register to comment.