Gentoo Archives: gentoo-user

From: Dale <rdalek1967@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Cron and disabling emails for one script only
Date: Tue, 06 Apr 2021 23:52:11
Message-Id: dc3f0498-a2dd-0b57-73cf-6939439267f2@gmail.com
In Reply to: Re: [gentoo-user] Cron and disabling emails for one script only by John Covici
1 John Covici wrote:
2 > On Tue, 06 Apr 2021 13:43:31 -0400,
3 > Dale wrote:
4 >> Howdy,
5 >>
6 >> I set up a hard drive to backup my emails, world file, /etc and a couple
7 >> other things.  I been doing it manually but finally set up a cron job to
8 >> run it automatically.  I call it a script but some may laugh at me
9 >> calling it that.  Anyway, I got cron to run it just fine.  It runs and
10 >> copies it over just like it should.  I set it to do that each hour. 
11 >> Thing is, it sends a email every time it does it.  I don't mind a email
12 >> if there is a error but don't want one if it runs successfully.  This is
13 >> the cron file I set up.  It's placed in the hourly directory.
14 >>
15 >>
16 >> #!/bin/bash
17 >> /root/mail-backup > /dev/null 2>&1 || true
18 >> # >/dev/null 2>&1
19 >>
20 >>
21 >> I got a lot of hits doing a google search and the only thing I see is to
22 >> direct it to /dev/null.  From examples I've seen, this should work.  I
23 >> then ran across the one currently up there with true in it.  I don't
24 >> understand that but tried it anyway.  It still sends emails.  I also
25 >> tried the one commented out below that as well.  Still emails. 
26 >>
27 >> Keep in mind, I do not want to disable ALL emails, just this one
28 >> script.  How does one disable emails for this one cron job?  Do I have a
29 >> typo or putting it in wrong place maybe?  Everything I found shows this
30 >> should work but obviously I'm doing something wrong.  Again, error
31 >> emails are fine.  I don't want successful runs tho. 
32 >>
33 >> Thanks much.
34 > I think you have to do it in your actual backup script or put the
35 > whole thing in the hourly directory putting >/dev/null at the end of
36 > each rsync command, but leaving off the 2>&1, so you will get error
37 > messages.
38 >
39
40
41 This seems to be working.  Since I added the null bit to the script
42 itself, it hasn't sent a email.  I don't know if it will if it fails but
43 I still have weekly backups as well. 
44
45 It seems I had the right option, just put it in the wrong place.  I
46 figured it would be something like that. 
47
48 Thanks to all.
49
50 Dale
51
52 :-)  :-) 

Replies

Subject Author
Re: [gentoo-user] Cron and disabling emails for one script only Neil Bothwick <neil@××××××××××.uk>