Cron to delete email help needed


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cron to delete email help needed
# 1  
Old 03-30-2009
Question 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 PERL/usr/bin/perlPath to sendmail/usr/sbin/sendmailInstalled Perl ModulesClick to ViewPHP version5.2.8MySQL version5.0.67-communitycPanel Build11.24.4-RELEASE 34599ThemecPanel X v2.6.0
# 2  
Old 03-30-2009
well, to delete all mail in an inbox, without reading it you can
Code:
cat /dev/null >/var/spool/mail/<username>

so a cronjob to do that would look like
Code:
13 5 * * * cat /dev/null >/var/spool/mail/<username> 2>/dev/null

which will run at 05:13 every day
btw, in case you were wondering, the 2>/dev/null at the end of the line will stop any error output from the cat command, because if there is any output at all cron will mail it to you, and if it is your inbox that you are deleting, then that would defeat the object.
This User Gave Thanks to wempy For This Post:
# 3  
Old 05-27-2009
The script that I use as a cron job is :-

Code:
#!/bin/sh

echo 'd *' | mail -N

exit 0

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

2. Shell Programming and Scripting

Help needed for sending email attachment

Hi Please help me how to send email attchment from linux server to outlook id I dont have uuencode or mutt installed on my machine and below is my uname -a output: Linux xxxxxxx 2.6.18-308.4.1.el5 #1 SMP Wed Mar 28 01:54:56 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux (7 Replies)
Discussion started by: buzzme
7 Replies

3. Red Hat

Email program using CRON

Hi Guys... I have a bulk email program that sends out an email to a subscribed mail list. The list contains around 2000 addresses. My server is Centos 5 64bit PHP 5.2 Mysql 5.1 The program is set to send emails in batches of 100. Cron is set to run every minute Now for the problem:... (2 Replies)
Discussion started by: countrydj
2 Replies

4. Ubuntu

Command line email help needed

Hi, having some problems getting commandline mail to work for root user in ubuntu. Ive installed the following packages - msmtp & mailx and the cert for gmail. I've created 3 files: mailrc and msmtprc in /home/username directory and /etc/exim4/passwd.client mailrc ------ set... (0 Replies)
Discussion started by: ziggycat
0 Replies

5. UNIX for Advanced & Expert Users

Email engine cron problem.

We have an email engine in our corporation which is installed in Solaris based machine. It is currently facing delays in transactions. So a temporary work around was deployed that is a cronjob was made for restarting email engine every hour. We tested in lab system and it worked pretty okay but in... (10 Replies)
Discussion started by: nixhead
10 Replies

6. Shell Programming and Scripting

Help needed to send email

Hi , Below is the part of Ksh.I have written. The sql below generates list of records for undelivered letters. ## - spool undelivered letter list cd $cs_LOG $ORACLE_BIN/sqlplus $USER/$PASS @$cs_PROG/spool_undelivered_letters.sql The below Ksh check for the file and send emails. ... (1 Reply)
Discussion started by: sithara
1 Replies

7. Shell Programming and Scripting

Help needed to send email

Hi , Below is the part of Ksh.I have written. The sql below generates list of records for undelivered letters. ## - spool undelivered letter list cd $cs_LOG $ORACLE_BIN/sqlplus $USER/$PASS @$cs_PROG/spool_undelivered_letters.sql The below Ksh check for the file and send emails. ... (3 Replies)
Discussion started by: sithara
3 Replies

8. Forum Support Area for Unregistered Users & Account Problems

Help needed on cron job

Hi Yogesh, I have a script where i have set up a cron job. The script is running manually. The cron job is running successfully. The script is written so that whenever the database link is down, we need to get an alert mail. We are getting the mail when we run the script manually but not when... (4 Replies)
Discussion started by: sanei05
4 Replies

9. UNIX for Dummies Questions & Answers

Cron Email Problem

I have two different cron jobs that run on the same days. The jobs are 7 hours apart. Both jobs are set to send notification emails when they start running. Both jobs always run successfully, but I only receive an email from the first job. I never get the email from the second job. ... (0 Replies)
Discussion started by: sasaliasim
0 Replies

10. UNIX for Dummies Questions & Answers

email when cron fails

I have a cronjob scheduled to run everyday. How can I obtain an email if and only if the cronjob fails? I am using Sun Solaris (ksh). :rolleyes: (7 Replies)
Discussion started by: inpavan
7 Replies
Login or Register to Ask a Question