Creating a cron job to delete files
Hello,
Can anyone tell me what the correct syntax is to "create" a cron as root that would "Delete cp bandwidth files on a yearly basis"?
What I have so far, untested..
1 0 1 1 * rm -rf /var/cpanel/bandwidth/*.sqlite > /dev/null 2>&1
If correct, where is cron tab location, and how should this be created using linux cmd?
Also, do I need last part? "> /devnull 2>&1".
Thanks.
-
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 -
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.
Comments
2 comments