Need to send mail only when the job is not running


 
Thread Tools Search this Thread
Special Forums UNIX Desktop Questions & Answers Need to send mail only when the job is not running
# 1  
Old 03-18-2016
Error Need to send mail only when the job is not running

I have set up a cron, which will send the mail with not runnnig jobs in the script.sh

15,30,45 * * * * /a/b/c/script.sh | grep not | mail -s "test mail" learner987@gmail.com

But i dont want mail when all the jobs are running, but with the above cron i will get mails without the content(if all the jobs are running).
Please suggest.
# 2  
Old 03-18-2016
man crontab:
Quote:
In addition to LOGNAME, HOME, and SHELL, cron(8) will look at MAILTO if it has any reason to send mail as a result of running commands in ``this'' crontab. If MAILTO is defined (and non-empty), mail is sent to the user so named. MAILTO may also be used to direct mail to multiple recipients by separating recipient users with a comma. If MAILTO is defined but empty (MAILTO=""), no mail will be sent. Otherwise mail is sent to the owner of the crontab.
# 3  
Old 03-18-2016
Thanks RudiC
but MAILTO is not present in my machine and i dont have permission also.
Is there any other way for it, like by using 'if' command or something.
Can you assist by giving an example.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. UNIX for Beginners Questions & Answers

Grep the 'not running' jobs and will send the update in mail with its name(job)

my request is: i have to create a script , which will grep the 'not running' jobs and will send the update in mail with its name(job) Scenario: logged in to machine abc went to particular path: cd /a/b/c then ./script1.sh status (script.sh is a script,whose status gives info about 10 jobs... (1 Reply)
Discussion started by: learner987
1 Replies

3. Ubuntu

Not able to send mail out of UbuntuBox in send mail

Hi Guys.. yesterday i purchased a VPS server and installed sendmail on ubuntu 12.4 with Webmin & Apache runing webserver problem is.. i can send mail via webmin user interface account to anybody to out side to any domain and able to recieve any mail from any domain.. Now main... (2 Replies)
Discussion started by: cmdman
2 Replies

4. Shell Programming and Scripting

How to send mail using PHP mail function On apache server.?

Hello, I am using centos-6.2 I have apache server,php5 on my system and I want to send mail using sendmail on my system. when I try to send mail from shell that time mail is succesfully sent to respective address() but when I try to send it through webbrowser I am not able to send it.... (1 Reply)
Discussion started by: Kiran ursal
1 Replies

5. Shell Programming and Scripting

how to run a script using cron job and send the output as attachment via e-mail using unix

how to run a script using cron job and send the output as attachment via e-mail using unix. please help me. how my cron job entry should be? As of now my cron job entry is to run the script at specific time, 15 03 * * * /path/sample.sh | mail -s "Logs" email_id In the above entry, what... (8 Replies)
Discussion started by: vidhyaS
8 Replies

6. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

7. Shell Programming and Scripting

Calling SQL script from ksh job and send mail on some error.

Hi, I am trying to call sql script from ksh job with parameters.The parameters passed from ksh job will be used in SELECT query in sql file to SPOOL the data in extract file.My questions are: 1) How to call a sql script from ksh job with parameters? 2) How to use the parameter in sql file to... (1 Reply)
Discussion started by: anil029
1 Replies

8. AIX

Able to send mail without running MTA (sendmail)?

Hi, I am facing a (for me and coworkers) strange behaviour. When I stop sendmail on a plain AIX 5.3 testing box (there is definetly no sendmail process left running anymore), I am still able to send mails to remote addresses via the mail command. I tried that on another box which is not a... (6 Replies)
Discussion started by: zaxxon
6 Replies

9. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

10. Shell Programming and Scripting

send mail after script finishes running

Hi All, We now have a Log file which has time stamps of all the scripts ran. It has start time and end time. I now have a requirement to send mail to the Admin after the script finishes running. Can some one help me with a Script which will send mail with Start time and End time of the... (2 Replies)
Discussion started by: srikanthgr1
2 Replies
Login or Register to Ask a Question