Delete Old Spam Emails Custom Cron


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Delete Old Spam Emails Custom Cron
# 1  
Old 07-29-2008
Delete Old Spam Emails Custom Cron

Hey Guys,

I've done some research however I got stuck. My goal is to create a cron job that runs every hour and goes through all web accounts on my server and deletes spam emails that are older than 3 days. This is what I came up with:

Code:
0 * * * * find /home/*/mail/*/*/.spam/cur/* -type f -mtime +3 -exec rm{}

HOWEVER Smilie ... when i test just a piece of that command:

Code:
find /home/*/mail/*/*/.spam/cur/* -type f -print |xargs ls|wc -l

I get the pretty "Argument list too long" error. I dont want to proceed setting up that cron job until I'm 100% sure that it is correct and will work on all user accouts with some of them having over 50,000 spam emails in ther .spam/cur folder. Any advice?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Emergency UNIX and Linux Support

How to prevent emails as spam?

If an email is sent from our application server(running on AIX) to an id that is outside of the organization like gmail etc, and if gmail should not treat the mail as spam, what has to be done from unix level? (7 Replies)
Discussion started by: ggayathri
7 Replies

2. Shell Programming and Scripting

How to disable cron emails, but only for logrotate only not for other logs?

Guys, is there a script or command? how to disable cron emails, but only for logrotate only not for other logs (3 Replies)
Discussion started by: kenshinhimura
3 Replies

3. Shell Programming and Scripting

Shell Script to Delete Old Cron Jobs

I have a cron entry to deploy a website portal from a staging server to a series of production servers on a weekly basis. On occasion, a random office worker who knows nothing about Linux let alone cron, will be tasked to update news picks on the staging server and then run a manual deployment... (2 Replies)
Discussion started by: AndrewT
2 Replies

4. Shell Programming and Scripting

Using cron to delete directories 90 days old

We use Solaris 10 x86 and I want to use a cron job to remove directories +90 old. Currently I have the command below but it only cleans the files and keeps the directory. What am I doing wrong? /opt/tesk/batch/kit/archive/* -mtime +90 -exec rm -r {} \: Thank you (3 Replies)
Discussion started by: oh-daa
3 Replies

5. UNIX for Dummies Questions & Answers

Cron to delete email help needed

I would like to know if I can place a cron job (and what it might be of course) to delete all the mail in an inbox? Here are the servers specs: Operating systemLinuxService StatusClick to ViewKernel version2.6.28.9Machine Typei686Apache version2.2.11 (Unix)PERL version5.8.8Path to... (2 Replies)
Discussion started by: markmatu
2 Replies

6. UNIX for Dummies Questions & Answers

Cron job to delete files

Hi everyone! I'm sorry, I'm a total noob but would really appreciate any advice or help. I want to create a cron job that would run every hour and would look inside a few different folders. If any new files were created within those folders within the last hour they would be destroyed, but any... (2 Replies)
Discussion started by: jessn
2 Replies

7. UNIX for Dummies Questions & Answers

CRON. How to delete files within a directory

I'd like to delete ALL files on a daily basis within a directory that are over a day old. Anyone know how I can automate this through Cron as I have 146 websites to administer. I've tried... 30 02 * * * /home/myspace/tmp/webalizer -atime + 1\! -type d -exec rm -f {} \; but all i get is an... (1 Reply)
Discussion started by: southoxon
1 Replies

8. UNIX for Dummies Questions & Answers

How do we delete spam email on mmdf

Please advise on how to delete spam email from mmdf email, and The Unix spec below: System = SCO_SV Release = 3.2v5.0.5 (2 Replies)
Discussion started by: esh
2 Replies
Login or Register to Ask a Question
cron(1M)						  System Administration Commands						  cron(1M)

NAME
cron - clock daemon SYNOPSIS
/usr/sbin/cron DESCRIPTION
cron starts a process that executes commands at specified dates and times. You can specify regularly scheduled commands to cron according to instructions found in crontab files in the directory /var/spool/cron/crontabs. Users can submit their own crontab file using the crontab(1) command. Commands which are to be executed only once can be submitted using the at(1) command. cron only examines crontab or at command files during its own process initialization phase and when the crontab or at command is run. This reduces the overhead of checking for new or changed files at regularly scheduled intervals. As cron never exits, it should be executed only once. This is done routinely by way of the svc:/system/cron:default service. The file /etc/cron.d/FIFO file is used as a lock file to prevent the execution of more than one instance of cron. cron captures the output of the job's stdout and stderr streams, and, if it is not empty, mails the output to the user. If the job does not produce output, no mail is sent to the user. An exception is if the job is an at(1) job and the -m option was specified when the job was submitted. cron and at jobs are not executed if your account is locked. Jobs and processses execute. The shadow(4) file defines which accounts are not locked and will have their jobs and processes executed. Setting cron Jobs Across Timezones The timezone of the cron daemon sets the system-wide timezone for cron entries. This, in turn, is by set by default system-wide using /etc/default/init. If some form of daylight savings or summer/winter time is in effect, then jobs scheduled during the switchover period could be executed once, twice, or not at all. Setting cron Defaults To keep a log of all actions taken by cron, you must specify CRONLOG=YES in the /etc/default/cron file. If you specify CRONLOG=NO, no log- ging is done. Keeping the log is a user configurable option since cron usually creates huge log files. You can specify the PATH for user cron jobs by using PATH= in /etc/default/cron. You can set the PATH for root cron jobs using SUPATH= in /etc/default/cron. Carefully consider the security implications of setting PATH and SUPATH. Example /etc/default/cron file: CRONLOG=YES PATH=/usr/bin:/usr/ucb: This example enables logging and sets the default PATH used by non-root jobs to /usr/bin:/usr/ucb:. Root jobs continue to use /usr/sbin:/usr/bin. The cron log file is periodically rotated by logadm(1M). FILES
/etc/cron.d Main cron directory /etc/cron.d/FIFO Lock file /etc/default/cron cron default settings file /var/cron/log cron history information /var/spool/cron Spool area /etc/cron.d/queuedefs Queue description file for at, batch, and cron /etc/logadm.conf Configuration file for logadm ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
svcs(1), at(1), crontab(1), sh(1), logadm(1M), svcadm(1M), queuedefs(4), shadow(4), attributes(5), smf(5) NOTES
The cron service is managed by the service management facility, smf(5), under the service identifier: svc:/system/cron:default Administrative actions on this service, such as enabling, disabling, or requesting restart, can be performed using svcadm(1M). The ser- vice's status can be queried using the svcs(1) command. DIAGNOSTICS
A history of all actions taken by cron is stored in /var/cron/log and possibly in /var/cron/olog. SunOS 5.10 5 Aug 2004 cron(1M)