Ticket #1217 (Faulty cron for removing old backend logs) created

  • [feedquote='Trac','http://trac.i-mscp.net/ticket/1217']

    The cronjob

    Code
    1. # Remove backend Logs older than 7 days
    2. @daily root /usr/bin/nice -n 19 /usr/bin/find /var/log/imscp/* -maxdepth 1 -type f -mtime +7 -print | xargs -r /bin/rm

    Does not work when files have spaces in them:

    Code
    1. /bin/rm: cannot remove `/var/log/imscp/Htaccess_mngr_Dungeons': No such file or directory
    2. /bin/rm: cannot remove `and': No such file or directory
    3. /bin/rm: cannot remove `Dragons.log': No such file or directory

    Fix/Workaround?:

    Code
    1. /usr/bin/nice -n 19 /usr/bin/find /var/log/imscp/* -maxdepth 1 -type f -mtime +7 -exec echo rm "{}" \;

    It's a bit inefficient, "rm" is executed once per file.

    Btw. the files should be prefixed with the client id, or there will be name clashes if another client creates a protected folder with the same name.
    [/feedquote]