Stopping emails from Cron. - Mandriva

This is a discussion on Stopping emails from Cron. - Mandriva ; I run getmail to download emails from my ISP, then I read them from there with Kmail. To run it, I have an entry in my user crontab file. Suddenly, I had 373 emails from crontab, one for each run ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Stopping emails from Cron.

  1. Stopping emails from Cron.

    I run getmail to download emails from my ISP, then I read them from there
    with Kmail. To run it, I have an entry in my user crontab file.

    Suddenly, I had 373 emails from crontab, one for each run of getmail, every
    3 minutes (which wasn't supposed to be, anyway.) man 5 crontab says that
    SysV can't prevent it happening. It contrasts SysV with BSD, so I assume
    that it still means Linux.

    Can I make a cron file like cron.daily to run more often than hourly? It
    should simply be a matter for example, of creating /etc/cron.quarter-hourly
    then setting its timing in the same way as with cron.daily. Woyuld this
    work?

    Doug.


  2. Re: Stopping emails from Cron.

    On Tue, 12 Feb 2008 17:53:24 +1100, Doug Laidlaw wrote:
    > I run getmail to download emails from my ISP, then I read them from there
    > with Kmail. To run it, I have an entry in my user crontab file.
    >
    > Suddenly, I had 373 emails from crontab, one for each run of getmail, every
    > 3 minutes (which wasn't supposed to be, anyway.) man 5 crontab says that
    > SysV can't prevent it happening. It contrasts SysV with BSD, so I assume
    > that it still means Linux.


    Only cron emails I get are the ones which send mail or have real failures.
    For null body text command line emails, I have to suppress info
    message about null body text. Cron script example snippet:

    /bin/mail -s "$1" $USER < /dev/null > /dev/null

    To suppress other messages I use the same kind of trick. Example:

    dcop kwin default setCurrentDesktop $_mail_desktop > /dev/null


    If I want command error messages:

    some_cmd_here any_argument_needed > $HOME/tmp/cmd.log 2>&1
    if [ $? -ne 0 ] ; then
    mail -s "cmd failure" $USER < $HOME/tmp/cmd.log > /dev/null
    fi


    > Can I make a cron file like cron.daily to run more often than hourly?


    Since cron runs each minute, I can not see why not.

    > It should simply be a matter for example, of creating /etc/cron.quarter-hourly
    > then setting its timing in the same way as with cron.daily.


    In my stupid opinion, you do not put user work in /etc/cron* file/dirs.

    I created $HOME/.cron and made it look almost like /etc/cron.*

    $ cd $HOME/.cron
    $ ls -al
    total 36
    drwxr-xr-x 7 bittwister bittwister 4096 2007-08-01 11:39 .
    drwxr-xr-x 23 bittwister bittwister 4096 2008-01-28 15:34 ..
    -rw-r--r-- 1 bittwister bittwister 1184 2007-06-29 16:26 cron.job
    drwxr-xr-x 2 bittwister bittwister 4096 2007-12-04 23:37 daily
    drwxr-xr-x 2 bittwister bittwister 4096 2008-02-12 04:02 flag
    drwxr-xr-x 2 bittwister bittwister 4096 2008-02-12 01:02 hourly
    drwxr-xr-x 2 bittwister bittwister 4096 2008-02-09 22:29 monthly
    -rw-r--r-- 1 bittwister bittwister 641 2006-07-25 17:40 todo.txt
    drwxr-xr-x 2 bittwister bittwister 4096 2008-01-28 15:34 weekly

    Like /etc/cron*, I put my cron scripts in whichever sub-directory I
    want the script executed.

    Root puts user in /etc/cron.allow,
    then sets the user's ~whoever/.cron/cron.job.

    # ls -al /var/spool/cron/bittwister
    -rw------- 1 bittwister bittwister 2007-12-03 15:42 /var/spool/cron/bittwister

    # cat /var/spool/cron/bittwister
    # DO NOT EDIT THIS FILE - edit the master and reinstall.
    # (cron.job installed on Sat Jun 19 21:49:26 2004)
    # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
    #*************** start of cron.job *********************************
    MAILTO=""
    ################################################## ##################
    # syntax example #
    #minute (0-59), #
    #| hour (0-23), #
    #| | day of the month (1-31), #
    #| | | month of the year (1-12), #
    #| | | | day of the week (0-6 with 0=Sunday)#
    #| | | | | command #
    #30 01 * * * /home/jim/bin/cleartmp #
    ################################################## ##################
    _cron_loc=/accounts/bittwister
    0 0-23 * * * /bin/nice -n 19 /usr/bin/run-parts $_cron_loc/.cron/hourly
    02 4 * * * /bin/nice -n 19 /usr/bin/run-parts $_cron_loc/.cron/daily
    12 4 * * 0 /bin/nice -n 19 /usr/bin/run-parts $_cron_loc/.cron/weekly
    22 4 1 * * /bin/nice -n 19 /usr/bin/run-parts $_cron_loc/.cron/monthly
    32 4 * * * /bin/nice -n 19 /local/bin/ck_mail_msg
    #************* end cron.job ****************************************

  3. Re: Stopping emails from Cron.

    Bit Twister wrote:

    > In my stupid opinion, you do not put user work in /etc/cron* file/dirs.


    Thanks. I worked that one out 5 minutes too late - after the message had
    gone. It would mean running the cron job as me.

    It is just that it hasn't done this until today - and suddenly there were
    375 messages. I updated the draktools last night. That may have something
    to do with it. Most of my cron jobs have "> /dev/null 2> /dev/null." This
    one doesn't. Adding it seems to have fixed the problem.

    Doug.

  4. Re: Stopping emails from Cron.

    Doug Laidlaw writes:

    >I run getmail to download emails from my ISP, then I read them from there
    >with Kmail. To run it, I have an entry in my user crontab file.


    Pipe the output to /dev/null, including the stderr.
    Now you might want to show us the entry in crontab file to see whether you
    have messed up.


    >Suddenly, I had 373 emails from crontab, one for each run of getmail, every
    >3 minutes (which wasn't supposed to be, anyway.) man 5 crontab says that
    >SysV can't prevent it happening. It contrasts SysV with BSD, so I assume
    >that it still means Linux.


    >Can I make a cron file like cron.daily to run more often than hourly? It
    >should simply be a matter for example, of creating /etc/cron.quarter-hourly
    >then setting its timing in the same way as with cron.daily. Woyuld this
    >work?


    Work for what? The problem is not clear.


    >Doug.



  5. Re: Stopping emails from Cron.

    On Wed, 13 Feb 2008 03:07:40 +1100, Doug Laidlaw wrote:

    > It is just that it hasn't done this until today - and suddenly there were
    > 375 messages. I updated the draktools last night. That may have something
    > to do with it. Most of my cron jobs have "> /dev/null 2> /dev/null."


    I would not recommend blindly using the /dev/null to suppress cron/at output.

    I would recommend doing a status check after commands to tell you
    about problems.

  6. Re: Stopping emails from Cron.

    Bit Twister wrote:

    > On Wed, 13 Feb 2008 03:07:40 +1100, Doug Laidlaw wrote:
    >
    >> It is just that it hasn't done this until today - and suddenly there were
    >> 375 messages. I updated the draktools last night. That may have
    >> something
    >> to do with it. Most of my cron jobs have "> /dev/null 2> /dev/null."

    >
    > I would not recommend blindly using the /dev/null to suppress cron/at
    > output.
    >
    > I would recommend doing a status check after commands to tell you
    > about problems.


    I see your point, but here the problem was the frequency. It was supposed
    to run every 10 minutes, but was running every 3. I thought that the
    spammers had eventually found me, with a vengeance!

    I would probably be more concerned about a system function than about a MTA.
    I rarely check logs unless there is a reason. This is principally because
    I run a workstation whose server functions seem to be blocked by my ISP. I
    run servers only for local use: mail, Leafnode and Apache. I used to be
    able to get out with Apache, but not any more. My external Web pages are
    all hosted externally. Much safer. But I have been setting up logging
    where it is only optional - just in case.

    Doug.

+ Reply to Thread