LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-13-2012, 03:57 AM   #1
sysmicuser
Member
 
Registered: Mar 2010
Posts: 332

Rep: Reputation: 0
Send email at a particular time without using crontab


Hi Folks,

Is there any way to send email at a particular time without using crontab?

say
mailx -s "Report for today `date +%d-%b-%Y`" test@testme.com < /tmp/temp

I want to send email but at a particular time of the day say 12.00am every day?

Is it possible without crontab?

Any clues...

Thanks
 
Old 03-13-2012, 04:51 AM   #2
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
You can write a script for sending mail daily.
Putting the above mailx command in a script you can do that. By the way don't you want to use crontab?
 
1 members found this post helpful.
Old 03-13-2012, 05:18 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
For a repeated task the best option is a crontab job. An alternative is at which is best suited for one-shot tasks, but you can always put your command line in a script and add some lines at the end to re-submit the at job later, e.g.
Code:
#!/bin/bash
mailx -s "Report for today $(date +%d-%b-%Y)" test@testme.com < /tmp/temp
at 12:00 tomorrow << EOF
$0
EOF
The first time you have to submit it manually, then it will re-submit itself automatically and indefinitely, until you change/remove the script and/or manually remove the current scheduled job.

Moreover, notice the at daemon is not enabled by default in all Linux distributions. Check you system to verify.
 
1 members found this post helpful.
Old 03-13-2012, 05:56 AM   #4
sysmicuser
Member
 
Registered: Mar 2010
Posts: 332

Original Poster
Rep: Reputation: 0
@Satayeer Arya
Quote:
You can write a script for sending mail daily.
Putting the above mailx command in a script you can do that.
How?
Can you give me or show me some practical example, I would truly appreciate that.

Your next question.
Quote:
By the way don't you want to use crontab
Politics at our work place is short answer.
Long answer, I have to go to change manager,expain him technical stuff, go to Unix administrators they will ask me again 20 different question, I don't want to bother myself with politics so I am thinking of any other/innovative way to make our life easy

Thank you.

@colucix
I myself understand and agree that crontab job is the best but as you would know from response above to Satyaveer Arya I want to explore another other which would do exactly same job like crontab.

Yes mailx daemon is running.

colucix, can you please confirm that
Code:
#!/bin/bash
mailx -s "Report for today $(date +%d-%b-%Y)" test@testme.com < /tmp/temp
at 12:00 tomorrow << EOF
$0
EOF
Once I run this script it would run indefinitely! ? that is all what I want
Can you please confirm which is this unix command
Code:
at 12:00 tomorrow << EOF
$0
EOF
I am not familiar with it.
I am quite comfortable with
Code:
mailx -s "Report for today $(date +%d-%b-%Y)" test@testme.com < /tmp/temp
This is just for my own knowledge sake.

Thank you.
 
Old 03-13-2012, 06:41 AM   #5
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Quote:
Can you please confirm which is this unix command
Check the man page of at command.

Code:
# man at
 
Old 03-13-2012, 08:20 AM   #6
sysmicuser
Member
 
Registered: Mar 2010
Posts: 332

Original Poster
Rep: Reputation: 0
Thank you all, this can now be closed as resolve "at" does the trick
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
help- how to reduce Size of Email attachment send via Crontab pnandak Linux - Newbie 18 02-29-2012 07:12 PM
Command based email client to send email through secure smtp havolinec Linux - Newbie 2 07-27-2010 08:40 AM
Perl email::send.. how to send the email? hawk__0 Programming 6 12-24-2009 02:53 PM
Can Apache send error messages (crit, warn & such) by email each time they get logged yogi799 Linux - Software 2 11-24-2009 04:08 PM
Script run by crontab won't send email Braynid Linux - Newbie 1 12-21-2007 01:16 AM


All times are GMT -5. The time now is 10:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration