Skip to main content

Creating a cron job to delete files

Comments

2 comments

  • cPRex Jurassic Moderator

    Hey there!  Deleting files with root, especially in an automated fashion through a cron job, is something that should be done with extreme caution. I'll outline each portion of the cron below, but it's up to you to ensure things work well on your system and you don't accidentally delete important data.

    I would start by running any command with "ls" instead of "rm" as that will show you what files will be removed with the command.  This allows you to confirm the filenames that will be removed.

    I do believe the rest of your syntax is correct to run a cron on the first day of the first month of the year.

    Root's crontab is edited with the "crontab -e" command.  That will open the cron file with the default text editor on the machine.

    The "/dev/null 2>&1" portion of the command is likely not necessary, but it sends any output to /dev/null so it isn't written to the terminal.

    0
  • cPanelPeter cPanel Staff

    Hello,  

    To add to the above from cPRex, the bandwidth files shouldn't be taking up a lot of space. Is there a reason you need to delete them? Doing so, won't give you much space back, as far as I know.  

    This will also remove historical data that could be beneficial to you later. 

     

    0

Please sign in to leave a comment.