LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-02-2019, 12:35 PM   #1
ChunkyDrew1965
LQ Newbie
 
Registered: Nov 2016
Location: Naranja, FL (Suburb of Miami)
Distribution: Ubuntu, Mint, Fedora
Posts: 3

Rep: Reputation: Disabled
Show before and after size in Cronjob email


I have a Ubuntu server which I connect to from several Linux boxes, and from Windows subsystem. I have one particular folder that I add to on a regular basis, and back up to an external drive nightly. The script checks the previous backup, and only backs up any changes from the previous night. I then run a script which notifies me by email that the job ran.
I would like to expand upon what I have by checking the size of that folder before and after the backup, and including that info in the email confirmation. I have attached the pertinent cronjob and email script.
Any suggestions would be greatly appreciated. It's okay for now, but it could definitely be improved.
Attached Thumbnails
Click image for larger version

Name:	Email Script2.jpg
Views:	14
Size:	21.6 KB
ID:	30998   Click image for larger version

Name:	Cronjob.PNG
Views:	12
Size:	13.9 KB
ID:	30999  
 
Old 08-02-2019, 01:00 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,752

Rep: Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223
Quote:
Originally Posted by ChunkyDrew1965 View Post
I have a Ubuntu server which I connect to from several Linux boxes, and from Windows subsystem. I have one particular folder that I add to on a regular basis, and back up to an external drive nightly. The script checks the previous backup, and only backs up any changes from the previous night. I then run a script which notifies me by email that the job ran.
I would like to expand upon what I have by checking the size of that folder before and after the backup, and including that info in the email confirmation. I have attached the pertinent cronjob and email script.
Any suggestions would be greatly appreciated. It's okay for now, but it could definitely be improved.
First: Please post code in code tags, not screenshots, when asking for this kind of help.

Second: What have you tried to do what you want to do? How do you 'check the size of a folder'? What would you do to include the results of the check in the email?
 
Old 08-02-2019, 01:41 PM   #3
ChunkyDrew1965
LQ Newbie
 
Registered: Nov 2016
Location: Naranja, FL (Suburb of Miami)
Distribution: Ubuntu, Mint, Fedora
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for your input. I included the screenshots because that allowed me to blot out my Gmail user name and password, which is included in my email script.
The email script I am running is one I found by searching the internet. It works for the basic notification, but I'm not proficient enough to edit it to meet my additional needs. At the command prompt, I have used: "du /media/chunkydrew/TranscendBkup/files/andrew/linuxdistros > /Home/size_before" & "/Home/size_after" to pipe the info I want into text files. What I want to do is modify the script to run the du commands before and after the cronjob and incorporate those results into my email results.
That may or may not be possible, but I'm not yet Linux-savvy enough to know how to do it.
 
Old 08-02-2019, 01:50 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,752

Rep: Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223Reputation: 2223
Quote:
Originally Posted by ChunkyDrew1965 View Post
Thanks for your input. I included the screenshots because that allowed me to blot out my Gmail user name and password, which is included in my email script.
The email script I am running is one I found by searching the internet. It works for the basic notification, but I'm not proficient enough to edit it to meet my additional needs. At the command prompt, I have used: "du /media/chunkydrew/TranscendBkup/files/andrew/linuxdistros > /Home/size_before" & "/Home/size_after" to pipe the info I want into text files. What I want to do is modify the script to run the du commands before and after the cronjob and incorporate those results into my email results.
That may or may not be possible, but I'm not yet Linux-savvy enough to know how to do it.
If you paste the text, you can change the data you don't want to share.

1. Backup the script
2. Add the du commands where you want them in the script
3. Put the contents of the files into the email, that is, into the MESSAGEBODY variable. See man cat

Last edited by scasey; 08-02-2019 at 01:51 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using CentOS 6.9 wget 1.14 cronjob but not pushing error exit status email skagnola Linux - Server 2 05-15-2018 09:01 AM
[SOLVED] Send email reposrt about cronjob abdoullah Linux - General 2 06-15-2011 01:00 PM
Email Myself Output of Cronjob? carlosinfl Linux - Server 15 05-21-2010 11:47 AM
run a shell script/cronjob when any email arrive to specific email address ikillu Linux - General 3 05-30-2009 08:18 AM
Total partition size - User partition size is not equals to Free partition size navaneethanj Linux - General 5 06-14-2004 12:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration