Re: [gentoo-user] Cron and disabling emails for one script only
Neil Bothwick wrote: > On Wed, 7 Apr 2021 03:22:18 -0500, Dale wrote: > This seems to be working. Since I added the null bit to the script itself, it hasn't sent a email. I don't know if it will if it fails but I still have weekly backups as well. >>> If you only redirect stdout to /dev/null and leave stderr alone, you >>> should still see errors. But a better option would be to have your >>> script only send output when something goes wrong. >> That sounds complicated. I've never been good at what y'all call >> scripting. I'm just glad it does it for me so I don't forget. > Not really. ">/dev/null" redirects stdout to null. You added 2>&1, which > redirects stderr to stdout, effectively throwing away any error messages. > Post your backup script and we'll be able to help more. > > I left the last bit off as well. I just put in the null part. I may do something to force it to screw up, like umount the drive, and see what it does. To be honest tho, I just wanted the emails to stop for that script. I have other backups anyway, just not as frequent. Dale :-) :_)
Re: [gentoo-user] Cron and disabling emails for one script only
On Wed, 7 Apr 2021 03:22:18 -0500, Dale wrote: > >> This seems to be working. Since I added the null bit to the script > >> itself, it hasn't sent a email. I don't know if it will if it fails > >> but I still have weekly backups as well. > > If you only redirect stdout to /dev/null and leave stderr alone, you > > should still see errors. But a better option would be to have your > > script only send output when something goes wrong. > That sounds complicated. I've never been good at what y'all call > scripting. I'm just glad it does it for me so I don't forget. Not really. ">/dev/null" redirects stdout to null. You added 2>&1, which redirects stderr to stdout, effectively throwing away any error messages. Post your backup script and we'll be able to help more. -- Neil Bothwick WinErr 815: Insufficient Memory - Only 50,312,583 Bytes available pgpBVLFfZkuHs.pgp Description: OpenPGP digital signature
Re: [gentoo-user] Cron and disabling emails for one script only
Neil Bothwick wrote: > On Tue, 6 Apr 2021 18:51:56 -0500, Dale wrote: > >>> I think you have to do it in your actual backup script or put the >>> whole thing in the hourly directory putting >/dev/null at the end of >>> each rsync command, but leaving off the 2>&1, so you will get error >>> messages. >> This seems to be working. Since I added the null bit to the script >> itself, it hasn't sent a email. I don't know if it will if it fails but >> I still have weekly backups as well. > If you only redirect stdout to /dev/null and leave stderr alone, you > should still see errors. But a better option would be to have your script > only send output when something goes wrong. > > That sounds complicated. I've never been good at what y'all call scripting. I'm just glad it does it for me so I don't forget. Dale :-) :-)
Re: [gentoo-user] Cron and disabling emails for one script only
On Tue, 6 Apr 2021 18:51:56 -0500, Dale wrote: > > I think you have to do it in your actual backup script or put the > > whole thing in the hourly directory putting >/dev/null at the end of > > each rsync command, but leaving off the 2>&1, so you will get error > > messages. > This seems to be working. Since I added the null bit to the script > itself, it hasn't sent a email. I don't know if it will if it fails but > I still have weekly backups as well. If you only redirect stdout to /dev/null and leave stderr alone, you should still see errors. But a better option would be to have your script only send output when something goes wrong. -- Neil Bothwick Windows - From the people who brought you EDLIN! pgpFpYIKzocva.pgp Description: OpenPGP digital signature
Re: [gentoo-user] Cron and disabling emails for one script only
John Covici wrote: > On Tue, 06 Apr 2021 13:43:31 -0400, > Dale wrote: >> Howdy, >> >> I set up a hard drive to backup my emails, world file, /etc and a couple >> other things. I been doing it manually but finally set up a cron job to >> run it automatically. I call it a script but some may laugh at me >> calling it that. Anyway, I got cron to run it just fine. It runs and >> copies it over just like it should. I set it to do that each hour. >> Thing is, it sends a email every time it does it. I don't mind a email >> if there is a error but don't want one if it runs successfully. This is >> the cron file I set up. It's placed in the hourly directory. >> >> >> #!/bin/bash >> /root/mail-backup > /dev/null 2>&1 || true >> # >/dev/null 2>&1 >> >> >> I got a lot of hits doing a google search and the only thing I see is to >> direct it to /dev/null. From examples I've seen, this should work. I >> then ran across the one currently up there with true in it. I don't >> understand that but tried it anyway. It still sends emails. I also >> tried the one commented out below that as well. Still emails. >> >> Keep in mind, I do not want to disable ALL emails, just this one >> script. How does one disable emails for this one cron job? Do I have a >> typo or putting it in wrong place maybe? Everything I found shows this >> should work but obviously I'm doing something wrong. Again, error >> emails are fine. I don't want successful runs tho. >> >> Thanks much. > I think you have to do it in your actual backup script or put the > whole thing in the hourly directory putting >/dev/null at the end of > each rsync command, but leaving off the 2>&1, so you will get error > messages. > This seems to be working. Since I added the null bit to the script itself, it hasn't sent a email. I don't know if it will if it fails but I still have weekly backups as well. It seems I had the right option, just put it in the wrong place. I figured it would be something like that. Thanks to all. Dale :-) :-)
Re: [gentoo-user] Cron and disabling emails for one script only
On Tue, 6 Apr 2021 14:42:28 -0500, Dale wrote: > > cron only sends an email if the job produces any output. If the script > > follows the *nix principle of succeed quietly, fail noisily, you > > should only get emails when things go wrong. However without seeing > > your mail-backup script, it is hard to say what needs to change. > > > > The "|| true " part means this cron task will always return success, > > even if the script fails, which possibly is not what you want. > > > > > > > My script, if one wants to call it that, just has rsync commands in it. > It doesn't get fancy. I literally copy the commands from Konsole and > paste them in my text file. I make it executable and that's my script. > I wouldn't even think it rises to a bash thing even tho it is at the > top, cron likes it that way. For years, I been doing it manually. I > just wanted to automate the thing a bit. But what are the rsync commands and what information does cron mail you? Without this information, we can only make wild guesses as to what is going on. As a first wild guess though, rsync has a --quiet option that means it only outputs error messages, are you using this? As John said, your cron script only calls the backup script, so you may as well put that in cron.hourly. -- Neil Bothwick ...Advert for restaurant: "Exotic foods for all occasions. Police balls a speciality." pgp3YI58o6QnE.pgp Description: OpenPGP digital signature
Re: [gentoo-user] Cron and disabling emails for one script only
On Tue, 06 Apr 2021 13:43:31 -0400, Dale wrote: > > Howdy, > > I set up a hard drive to backup my emails, world file, /etc and a couple > other things. I been doing it manually but finally set up a cron job to > run it automatically. I call it a script but some may laugh at me > calling it that. Anyway, I got cron to run it just fine. It runs and > copies it over just like it should. I set it to do that each hour. > Thing is, it sends a email every time it does it. I don't mind a email > if there is a error but don't want one if it runs successfully. This is > the cron file I set up. It's placed in the hourly directory. > > > #!/bin/bash > /root/mail-backup > /dev/null 2>&1 || true > # >/dev/null 2>&1 > > > I got a lot of hits doing a google search and the only thing I see is to > direct it to /dev/null. From examples I've seen, this should work. I > then ran across the one currently up there with true in it. I don't > understand that but tried it anyway. It still sends emails. I also > tried the one commented out below that as well. Still emails. > > Keep in mind, I do not want to disable ALL emails, just this one > script. How does one disable emails for this one cron job? Do I have a > typo or putting it in wrong place maybe? Everything I found shows this > should work but obviously I'm doing something wrong. Again, error > emails are fine. I don't want successful runs tho. > > Thanks much. I think you have to do it in your actual backup script or put the whole thing in the hourly directory putting >/dev/null at the end of each rsync command, but leaving off the 2>&1, so you will get error messages. -- Your life is like a penny. You're going to lose it. The question is: How do you spend it? John Covici wb2una cov...@ccs.covici.com
Re: [gentoo-user] Cron and disabling emails for one script only
Neil Bothwick wrote: > On Tue, 6 Apr 2021 12:43:31 -0500, Dale wrote: > >> Keep in mind, I do not want to disable ALL emails, just this one >> script. How does one disable emails for this one cron job? Do I have a >> typo or putting it in wrong place maybe? Everything I found shows this >> should work but obviously I'm doing something wrong. Again, error >> emails are fine. I don't want successful runs tho. > cron only sends an email if the job produces any output. If the script > follows the *nix principle of succeed quietly, fail noisily, you should > only get emails when things go wrong. However without seeing your > mail-backup script, it is hard to say what needs to change. > > The "|| true " part means this cron task will always return success, even > if the script fails, which possibly is not what you want. > > My script, if one wants to call it that, just has rsync commands in it. It doesn't get fancy. I literally copy the commands from Konsole and paste them in my text file. I make it executable and that's my script. I wouldn't even think it rises to a bash thing even tho it is at the top, cron likes it that way. For years, I been doing it manually. I just wanted to automate the thing a bit. I hope I don't have to learn bash to do this. I'd delete the cron job and just go back to doing it manually. lol Dale :-) :-)
Re: [gentoo-user] Cron and disabling emails for one script only
On Tue, 6 Apr 2021 12:43:31 -0500, Dale wrote: > Keep in mind, I do not want to disable ALL emails, just this one > script. How does one disable emails for this one cron job? Do I have a > typo or putting it in wrong place maybe? Everything I found shows this > should work but obviously I'm doing something wrong. Again, error > emails are fine. I don't want successful runs tho. cron only sends an email if the job produces any output. If the script follows the *nix principle of succeed quietly, fail noisily, you should only get emails when things go wrong. However without seeing your mail-backup script, it is hard to say what needs to change. The "|| true " part means this cron task will always return success, even if the script fails, which possibly is not what you want. -- Neil Bothwick The gene pool could use a little chlorine. pgpvuULBJcKJG.pgp Description: OpenPGP digital signature
Re: [gentoo-user] Cron and disabling emails for one script only
On 06/04/2021 18:43, Dale wrote: Keep in mind, I do not want to disable ALL emails, just this one script. How does one disable emails for this one cron job? Do I have a typo or putting it in wrong place maybe? Everything I found shows this should work but obviously I'm doing something wrong. Again, error emails are fine. I don't want successful runs tho. Are you sure? What if the job doesn't run (and doesn't send a failure message). Try and get it to use some distinguishing characteristic for your email client to separate success and failure. Then you can dump all your success messages into a folder that expires messages. If you suddenly discover you've got no messages your know your cron job is stuffed. If your job is stuffed you get the error email. Cheers, Wol
[gentoo-user] Cron and disabling emails for one script only
Howdy, I set up a hard drive to backup my emails, world file, /etc and a couple other things. I been doing it manually but finally set up a cron job to run it automatically. I call it a script but some may laugh at me calling it that. Anyway, I got cron to run it just fine. It runs and copies it over just like it should. I set it to do that each hour. Thing is, it sends a email every time it does it. I don't mind a email if there is a error but don't want one if it runs successfully. This is the cron file I set up. It's placed in the hourly directory. #!/bin/bash /root/mail-backup > /dev/null 2>&1 || true # >/dev/null 2>&1 I got a lot of hits doing a google search and the only thing I see is to direct it to /dev/null. From examples I've seen, this should work. I then ran across the one currently up there with true in it. I don't understand that but tried it anyway. It still sends emails. I also tried the one commented out below that as well. Still emails. Keep in mind, I do not want to disable ALL emails, just this one script. How does one disable emails for this one cron job? Do I have a typo or putting it in wrong place maybe? Everything I found shows this should work but obviously I'm doing something wrong. Again, error emails are fine. I don't want successful runs tho. Thanks much. Dale :-) :-)