Operating System - HP-UX
1833198 Members
2688 Online
110051 Solutions
New Discussion

Crontasks for root user not completing although tasks are executed

 
SOLVED
Go to solution
Kripal_1
Occasional Advisor

Crontasks for root user not completing although tasks are executed

Hi,
Some crontasks (only for root user) are failing with return code rc=1 in our system. (I could see this from cron log)
I modified crontab and removed redirection from tasks so that errors encountered while executing that task could
be sent as a message (mail) to the administrator. (read from 'mailx' using root# mailx) but unfortunately the mail
messages are not coming.
~~~~

50,54,58 * * * * csh -c 'nice $ROOT_HOME/lib/script/testscript.sh'

==> removed > /dev/null 2>&1 from the task
~~~~
I want to check the status of execution the crontasks to investigate why the tasks are not completing although the commands are executed by cron. Is there any other way out ???

I tried modifying crontab by redirecting the command stdout to some temp file :-
~~~~

50,54,58 * * * * csh -c 'nice $ROOT_HOME/lib/script/testscript.sh'> /tmp/testscriptlog.txt
~~~~

but it did not work only the file is created in /tmp, the error is not logged in the file.
kindly help with your suggestions.
3 REPLIES 3
Fred Ruffet
Honored Contributor
Solution

Re: Crontasks for root user not completing although tasks are executed

You must also redirect STDERR. This could be done with
... > /tmp/testscriptlog.txt 2>&1

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
john korterman
Honored Contributor

Re: Crontasks for root user not completing although tasks are executed

Hi,
try this csh redirection:

50,54,58 * * * * csh -c 'nice $ROOT_HOME/lib/script/testscript.sh' >&/tmp/testscriptlog.txt

but perhaps you should try first to only execute your program at 50 minutes; perhaps it has not finished before 54 - which could cause the problem.

regards,
John K.
it would be nice if you always got a second chance
Kripal_1
Occasional Advisor

Re: Crontasks for root user not completing although tasks are executed

Hi,
/tmp/testscriptlog.txt 2>&1
works thanks very much for your help

Rgds