LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-14-2013, 10:37 AM   #1
vxc69
Member
 
Registered: Jul 2004
Distribution: Ubuntu
Posts: 387

Rep: Reputation: 33
Shell: Sending an email after nohup command exits


Hi guys,


Just curious if this is possible. Say I put a long running process under nohup, background it then disown and logout.

Is it possible to have the system send a mail when the process exits (failed or not)?

If I can figure that out I can tail the nohup output and send myself a mail, stops me from having to login and check every now and then to see what is going on.


Thanks,
vxc

Last edited by vxc69; 05-14-2013 at 10:38 AM.
 
Old 05-14-2013, 10:44 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Code:
nohup run-some-long-command.ksh; tail nohup.out | mail schneidz@hyper -s "run-some-long-command.ksh finished"
edit: i just thought of something... the tail and mail commands mite not execute if you are no longer logged in ?
maybe create a small script and ran it using nohup:
Code:
#!/bin/bash
run-some-long-command.ksh > vxc69.log
tail vxc69.log | mail schneidz@hyper -s "run-some-long-command.ksh finished"

Last edited by schneidz; 05-14-2013 at 10:49 AM.
 
1 members found this post helpful.
Old 05-14-2013, 11:00 AM   #3
vxc69
Member
 
Registered: Jul 2004
Distribution: Ubuntu
Posts: 387

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by schneidz View Post
Code:
nohup run-some-long-command.ksh; tail nohup.out | mail schneidz@hyper -s "run-some-long-command.ksh finished"
edit: i just thought of something... the tail and mail commands mite not execute if you are no longer logged in ?
maybe create a small script and ran it using nohup:
Code:
#!/bin/bash
run-some-long-command.ksh > vxc69.log
tail vxc69.log | mail schneidz@hyper -s "run-some-long-command.ksh finished"
This should work, dunno why I didn't think of it!

Now to convince ppl at work to install sendmail - or else I can create a REST backend on a different server that does the mailing for me - ah that'll work just fine.


Thanks schneidz
 
  


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
[SOLVED] Sending email from command line through authenticated SMTP server xj25vm Linux - Server 7 12-11-2008 04:14 PM
command-line email sending ixion Linux - Software 9 08-01-2008 06:46 AM
problem with nohup command and nohup file size vbseeker Linux - General 1 09-17-2006 11:36 AM
command-line for sending email with attachment? enemorales Linux - Software 3 10-06-2004 08:04 AM
Sending Email's from command line jlaruffa Linux - Newbie 0 06-04-2003 03:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:52 PM.

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