Best way to handle old snapshots in local repository?

前端 未结 5 908
萌比男神i
萌比男神i 2021-02-19 06:35

We have a Nexus local repository manager which handles all our internal projects (as well as mirroring outside repositories). For our internal projects, we only keep the most

5条回答
  •  迷失自我
    2021-02-19 07:26

    On Linux, you can use this command:

    find $HOME/.m2/repository/ \
       -name "*-SNAPSHOT" \
       -type d \
       -mtime +60 \
       -print \
       -prune \
       -exec rm -r "{}" \;
    

    Explanation:

    • Find anything named *-SNAPSHOT in the folder $HOME/.m2/repository/
    • AND it must be a directory
    • AND it must not have been modified in the last 60 days
    • Print what you found. If you want to test the command, stop here
    • The -exec will delete the folder, -prune tells find not to try to enter the folder afterwards.
    • The -exec will delete the folder and files inside.

提交回复
热议问题