Operating System - HP-UX
1827280 Members
2458 Online
109717 Solutions
New Discussion

Cron job not running properly?

 
Tan Shirley
Frequent Advisor

Cron job not running properly?

Hello,

This is the second time I'm asking... Does anyone has any idea why do I keep receiving mails with subject 'cron' ??

Does it mean that my cronjob is not running properly?

Below is an example of one of the mails sent to root. Thanks !

------------------------------------------
Message 1:
From root@newmfg Fri Oct 13 14:00:00 EAT 2000
Received: (from root@localhost) by newmfg. (8.8.6 (PHNE_17190)/8.7.1) id OAA2718
2 for root; Fri, 13 Oct 2000 14:00:00 +0800 (EAT)
Date: Fri, 13 Oct 2000 14:00:00 +0800 (EAT)
From: root@newmfg
Message-Id: <200010130600.OAA27182@newmfg.>
Subject: cron
Status: RO

stty: : Not a typewriter


*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:

/mfgpro/admin/batch/hourly_dga > /mfgpro/batch/hourly_dga.mon

8 REPLIES 8
Alex Glennie
Honored Contributor

Re: Cron job not running properly?

Yes there's some problem with the script that's run by cron I think.

Try eliminating 'stty' and 'tty' from executing
script ( cron does not have an output channel) if these entries exist or post the script to the forum.
Andrew Lartey
Advisor

Re: Cron job not running properly?

Tan

it actually tells you at the bottom of the mail that the message is the Standard Out and Standard Error from your cron job.
It looks like the job is actually running , if you don't want the mail , put standard out and standard error either to a files (or files) or to /dev/null , in the crontab file
eg
.... your cron entry > /tmp/out 2>&1
or
.... your cron entry > /tmp/out 2>/tmp/error
or
.... your cron entry >/dev/null 2>&1

hope this helps
James R. Ferguson
Acclaimed Contributor

Re: Cron job not running properly?

Hi:

This behavior is "expected". Several recent thread have explained why this happens (under various circumstances) and how to eliminate the behavior. See:

http://my1.itrc.hp.com/cm/QuestionAnswer/1,1150,0x73e66c96588ad4118fef0090279cd0f9,00.html

http://my1.itrc.hp.com/cm/QuestionAnswer/1,1150,0x0c0c6d96588ad4118fef0090279cd0f9,00.html

From the command line you posted, I might guess that your script uses 'stty' in it. If that is the case you should execute it conditionally by building a test: [-t -eq 0].

Hopefuly this answers your question.

...JRF...

Alex Glennie
Honored Contributor

Re: Cron job not running properly?

& keep an eye out for entires like : stty erase '^H' in .kshrc etc thye should go in a users .profile I beleive and cause this exact type of problem.
Andreas Voss
Honored Contributor

Re: Cron job not running properly?

Hi,

you could also redirect error messages to your outputfile with crontab entry:
/mfgpro/admin/batch/hourly_dga > /mfgpro/batch/hourly_dga.mon 2>&1

Regards

John Palmer
Honored Contributor

Re: Cron job not running properly?

Hi,

It looks as though your script is issuing a command of the form 'su -c ' and consequently executing the standard /etc/profile and .profile scripts for that user.

By default, the .profile script runs 'stty' which fails as it is not connected to a terminal causing your message.

There are a couple of workarounds:-

1. change 'su - ' to su in your script. You would have to check that nothing that the .profile script does is required.

2. Put a test around the stty statements in .profile to stop them running if no terminal is associated - of the form:-

if [[ -t 1 ]];
then stty ...
fi

Regards,
John
Madanagopalan S
Frequent Advisor

Re: Cron job not running properly?

the script writes some error message to standard error. log the error
to file using 2> or if you want to write error to output file then

use 2>&1 at the end of the command.

like
script_name > output_file_name 2>&1 (this is to write the error to the output file name)
let Start to create peaceful and happy world
federico_3
Honored Contributor

Re: Cron job not running properly?


Your messages are generated from the stty command. This command either is trying to change terminal behavior but when doing by cron there is no terminal assosiated with a terminalor or is using the su command and a
$HOME/.profile is executed.
In order to fix this put for any stty commands (in .profile ) :
if [ -t ]
then
stty .....
fi
This way the stty command will be executed only if associated to a terminal.


Regards,

federico