Trending October 2023 # Have Linux Send You An Email Notification After Task Completion # Suggested November 2023 # Top 13 Popular | Vibergotobrazil.com

Trending October 2023 # Have Linux Send You An Email Notification After Task Completion # Suggested November 2023 # Top 13 Popular

You are reading the article Have Linux Send You An Email Notification After Task Completion updated in October 2023 on the website Vibergotobrazil.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested November 2023 Have Linux Send You An Email Notification After Task Completion

Having an alert sent to you through email can be very useful. For example, if you have a large build being done in the background, it makes no sense to wait around for the process to finish. In such cases, you can have Linux send you a message once the build is done. It saves you a lot of time. You can also have an email alert sent to you at a certain time. If you have an engagement in the evening, you can program it into Linux so you don’t forget!

First, let’s take a quick look at how you can send an email to yourself. The command for it is “mailx” or “mail“. This command may be different on your system, depending on the version of Linux you’re running (and it will only work if the server has been setup properly). The command syntax is:

Getting Linux to Trigger an Email Alert

Now, we can couple the command we used above with a conditional statement. This means that when the condition is satisfied, an email will be sent to you. Enter the following in the command line:

while

:;

do

date

;

ping

–c1 servername

&&

break

;

done

; mail

If you look closely, the code above is an infinite loop. When your system pings the server (servername), the loop gets broken and a mail will be sent to you. You don’t need to wait until a server has booted up or updated.

If you’re worried about system resources being spent, you can put the system to sleep by amending the command a little:

while

:;

do

date

;

ping

–c1 servername

&&

break

;

sleep

200

;

done

; mail

In this case, the computer will sleep for 200 seconds before it executes a new cycle. You also get a regular alert (that the loop is working) every few seconds this way.

You can put virtually any shell command as the condition (so long as it’s sensible and doesn’t overload your system):

while

:;

do

date

; the_command_to_be_executed

&&

break

;

done

; mail

What if you wanted to email yourself on a certain date at a certain time? You can change the command above a little like this:

while

[

date

+

"%T"

-gt

'06:00:00'

]

;

do

date

; the_command_to_be_executed

&&

break

;

done

; mail

If you were looking to receive notifications whenever you receive an email on your Linux system, you can install applications that support email notifications. Two of the more popular applications are PopTray Minus and Mail Notification.

You can experiment with the commands given above. The premise is simple – just design a condition statement which, when met, will trigger an email alert. If you need more info or help on how to use mailx, simply type “mailx --help“to display the help list.

Image Credit: tux flag linux penguin red waving , gray mail envelope white postal letter, memory reminders reminder dimensional control

Richa

I’m a techie with over a decade of programming experience, spread across a wide range of interesting, path breaking technologies. Now I’m sharing my passion for technology, and making tech easier, with everyone! Hope you enjoy reading about, and playing with technology, as much as I do!

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

You're reading Have Linux Send You An Email Notification After Task Completion

Update the detailed information about Have Linux Send You An Email Notification After Task Completion on the Vibergotobrazil.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!