Sponsored Content
Full Discussion: email when cron fails
Top Forums UNIX for Dummies Questions & Answers email when cron fails Post 17449 by LivinFree on Friday 15th of March 2002 09:01:26 AM
Old 03-15-2002
What I meant by exit code is the value of $?.
Under normal circumstances, like a successfully run command, the exit code will be 0. If there's an error, it will be something else. The sample script above checks to make sure that $? = 0, and if not, it will send an email.
The concern I have is that something in whatever script is run may run successfully after the failed command... I don't know if I'm explaining very well, so I'll try to show you:
Code:
$ cat tmp1.sh
#!/bin/sh
echo
wuzzle

$ ./tmp1.sh

./tmp1.sh: wuzzle: command not found
$ echo $?
127
$ cat tmp2.sh
#!/bin/sh
wuzzle
echo

$ ./tmp2.sh
./tmp2.sh: wuzzle: command not found

$ echo $?
0

So, you see, unless you told the fullback script to "exit 1" (or exit anything not equal to 0) after any component failed, it might not email you if it does fail.

It depends completely on your script (the fullback.ksh one), is should be easy to make sure it does this correctly...

On the other hand, if you're going to be rewriting to do this, why not put them all together into one? Here's a very simple example:
Code:
#!/usr/bin/ksh
/bin/tar vcf /dev/rmt/0 /home/admin >/var/adm/backup_log 2>&1
if [[ $? -ne 0 ]]; then
/bin/mail admin <<EndOfMail
Subject: Your backup had errors

See the contents of /var/adm/backup_log
for more details.
.
EndOfMail
fi

I guess it all depends on what you're trying to do.

And please let me know if I don't make any sense... I'm kind of tired here Smilie
 

10 More Discussions You Might Find Interesting

1. Solaris

Created cron.allow file and now email fails

Getting ready for Sarbanes Oxley and I was told that I need to create a cron.allow file for the box so that only specified users can create cron jobs. That was easy enough, and I put in all the accounts that had scheduled cron jobs such as: root lp My oracle account A couple of programmer... (1 Reply)
Discussion started by: citrowske
1 Replies

2. UNIX for Dummies Questions & Answers

Cron Email Problem

I have two different cron jobs that run on the same days. The jobs are 7 hours apart. Both jobs are set to send notification emails when they start running. Both jobs always run successfully, but I only receive an email from the first job. I never get the email from the second job. ... (0 Replies)
Discussion started by: sasaliasim
0 Replies

3. Shell Programming and Scripting

Running script that sends an html formatted email fails when its run as cronjob

Hi Im very new at working with unix and this problem I simply can not understand. I know there are a lot of threads about problems with shell scripts behaving differently when run from a terminal and from a cronjob. I have tried everything(almost) but I still havent cracked this problem. Im... (15 Replies)
Discussion started by: Nightowl
15 Replies

4. Shell Programming and Scripting

Cron job fails, but works fine from command line

I have a very basic script that essentially sends a log file, via FTP, to a backup server. My cron entry to run this every night is: 55 23 * * * /usr/bin/archive_logs The script runs perfectly when executed manually, and actually worked via cron for about three weeks. However, it mysteriously... (3 Replies)
Discussion started by: cdunavent
3 Replies

5. Shell Programming and Scripting

cron entry fails.

Hello, I have added the following entry in my cron file: * * * * * . /home/texprd/.profile>/dev/null 2>&1; echo "test" >> /home/texprd/test.log 2>&1 The cron fails ie the added command fails to append "test" in the test.log file. However if I run the command manually from the shell... (3 Replies)
Discussion started by: mahive
3 Replies

6. UNIX for Dummies Questions & Answers

If FTP cron job fails to connect = quit

Im having a problem with my ftp CRON jobs. I have another related (but not the same question in shell scripting). My FTP CRON jobs connect to a server and drop some files off, if for some reason it cannot connect to the server (timesout/password wrong etc) instead of stopping, it tries again... (3 Replies)
Discussion started by: mokachoka
3 Replies

7. UNIX for Advanced & Expert Users

Cron job fails every now and then.

I added a shell script to cron that executes every 5-15 minutes. It's used to monitor multiple environments, so it has to ssh to each machine to check the status of that machine. Sometimes, I may have more than one instance of this script running at the same time. So, here's my problem. I've... (2 Replies)
Discussion started by: mrwatkin
2 Replies

8. Red Hat

Email program using CRON

Hi Guys... I have a bulk email program that sends out an email to a subscribed mail list. The list contains around 2000 addresses. My server is Centos 5 64bit PHP 5.2 Mysql 5.1 The program is set to send emails in batches of 100. Cron is set to run every minute Now for the problem:... (2 Replies)
Discussion started by: countrydj
2 Replies

9. Shell Programming and Scripting

Cron job fails with [DataDirect][ODBC lib] Connection not open error

Hi, When run the script directly...it executes as expected. But when put it in crontab the job fails with this error: Connection not open 08003: Connection not open Unable to connect to the database... how come it is not able to connect when cron job fires?... Do I need to... (7 Replies)
Discussion started by: nuthakki
7 Replies

10. Shell Programming and Scripting

Script fails to send out email when HOSTNAME is included

Hi, Below is my script which sends out emails. more test.sh 1 #!/bin/ksh 2 { 3 print "From: Prod@mycomp.com" 4 # print "From: Prod@`hostname`.com" 5 # print "From: Prod@${HOSTNAME}.com" 6 print "To: me@mycomp.com" 7 print "Subject:... (5 Replies)
Discussion started by: mohtashims
5 Replies
LDAP2REPOSITORY(1)					User Contributed Perl Documentation					LDAP2REPOSITORY(1)

NAME
ldap2repository - creating debian repositories cronjob for the GOsa FAI plugin. SYNOPSIS
ldap2repository [-hvnpej] [-c config] [-d outdir] [-r srvroot] [-i interface] [-a arch] [-P proxy] DESCRIPTION
ldap2repository is a script to create the cronjob for the local. debian repositories needed by GOsa FAI plugin. -c LDAP config file (default: /etc/ldap/ldap.conf) -d output dir (default: /etc/gosa/fai) -h display this help and exit -n skip cleanup for mirrors -p show progress in cronjob -v be verbose -i network interface (default: eth0) -j create a new /etc/cron.d/goto-fai-backend -r server root (default: /srv/www) -e ignore small errors -a processor architecture (default: i386) -P proxy (default: none) BUGS
Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa-devel@oss.gonicus.de> or to <https://oss.gonicus.de/labs/gosa> LICENCE AND COPYRIGHT
This code is part of GOsa (<http://www.gosa-project.org>) Copyright (C) 2005-2006 Jan-Marek Glogowski <glogow@fbihome.de> 2007-2010 The GOsa project <gosa-devel@oss.gonicus.de> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. perl v5.10.0 2010-05-19 LDAP2REPOSITORY(1)
All times are GMT -4. The time now is 01:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy