I’ve been using the same server for about 6 years now. When I set it up, I chose to go with a Linux server because it was the cheaper option. At the time, I knew NOTHING about Linux. Since then, I’ve tried Mandriva, Fedora, and now run Ubuntu alongside XP. One thing that always got on my nerves was having to constantly go in and manually delete all of my spam using NeoMail. I knew cPanel had a cron interface, but never got around to using it. So one afternoon, instead of spending 3 hours deleting a 50MB spam file item by item, I decided to give cron a shot- and it’s much easier than I had previously thought! This quick tutorial will show you two ways of using crontab to automate the removal of a spamfile- one with the cpanel interface, and one without.
The Easy Way: cPanel’s Standard Interface
- Locate your mail folder. in most cases, this is simply “/mail”
- This folder contains all of your e-mail accounts, ordered by domain. For example, my e-mail address, george@georgegumpert.com is held in /mail/georgegumpert.com/george. Locate your spam file here. For me, this is simply called spam, so it would be /mail/georgegumpert.com/george/spam. This is the example I will use for the remainder of this tutorial
- In your cPanel interface, click “Cron Jobs” under “Advanced”
- Choose “Standard”
- For “Command” enter (without quotes): “rm -f /mail/georgegumpert.com/george/spam” This is telling it to delete (rm) the spam file (/mail/georgegumpert.com/george/spam) without asking for verification (-f). You don’t want it to ask for verification, because you won’t be there to give it, since this is an automated job.
- Now choose when to run it. For me, this is Minutes: 0, Hours: 3 = 3AM, Days: Every Day, Months: Every Month, Weekdays: Sunday. This will run it every Sunday at 3AM. It could be a bit excessive, but you don’t know my spam file!
- Press “Save Crontab” and you’re done!
The (Somewhat) Hard(er) Way: cPanel’s Advanced Interface
- Locate your mail folder. in most cases, this is simply “/mail”
- This folder contains all of your e-mail accounts, ordered by domain. For example, my e-mail address, george@georgegumpert.com is held in /mail/georgegumpert.com/george. Locate your spam file here. For me, this is simply called spam, so it would be /mail/georgegumpert.com/george/spam. This is the example I will use for the remainder of this tutorial
- In your cPanel interface, click “Cron Jobs” under “Advanced”
- Choose “Advanced (Unix Style)”
- Here you will be presented with a few cryptic boxes, labeled Minute, Hour, Day, Month, Weekday, Command. Simply enter the values (in 24-hour format, with Sunday being 0!) to have the command run at a specific time. For example, to have it run every Sunday at 3AM, fill in the following values:
Minute Hour Day Month Weekday Command 0 3 * * 0 rm -f /mail/georgegumpert.com/george/spam - Press “Commit Changes” and you’re done!
From The Terminal
Running crontab and setting up jobs from the terminal is not much different from using cpanel’s advanced interface.
- Locate your mail folder. in most cases, this is simply “/mail”
- This folder contains all of your e-mail accounts, ordered by domain. For example, my e-mail address, george@georgegumpert.com is held in /mail/georgegumpert.com/george. Locate your spam file here. For me, this is simply called spam, so it would be /mail/georgegumpert.com/george/spam. This is the example I will use for the remainder of this tutorial.
- In your terminal, create a crontab entry. Do this by typing crontab -e. This will open the crontab editor.
- Keeping with my previous examples, we’ll delete the mail file at 3am every Sunday. So on a new line, you enter: 0 3 * * 0 rm -f /mail/georgegumpert.com/george/spam (for an explanation of this, see “cPanel’s Advanced Interface” above.
- Write it out by pressing CTRL-O, and you’re good to go! You can verify the existence of this job by typing crontab -l.
Do this for each e-mail account, and there you have it! Enjoy never having to go in and manually delete your spam file again!
Related posts:




