Operating System - HP-UX
1748126 Members
3261 Online
108758 Solutions
New Discussion юеВ

Re: Program can not be run in the cron environment

 
SOLVED
Go to solution
Horia Chirculescu
Honored Contributor

Re: Program can not be run in the cron environment

>dmcutil is invoked by dmcManage.sh. However, there is a little difference, when executed in the above script, no rc=137 was reported.

Do you mean that starting dmcManage from cron is working as expected?

5 * * * * dmcManage.sh >> /tmp/test.log
works?

If this is the case, then take a look at dmcManage.sh script. Copy dmcManage.sh as dmcutil.sh and comment out in this file the other calls (except for dmcutil). Keep the defined shell and environment. Do not forget to chmod a+x the script.

Maybe post here this script.

Best regards
Horia.
Best regards from Romania,
Horia.
Dennis Handly
Acclaimed Contributor

Re: Program can not be run in the cron environment

>I added the script into the cron job

I don't see a script, I see an executable. Which is it? dmcManage.sh or dmcutil?

>when executed in the above script, no rc=137 was reported.

You are getting signal 9, SIGKILL. Have you exported LD_LIBRARY_PATH to the proper shlib paths?
What's in /tmp/test.log?
Did you get a mail message with the error?
Viktor Balogh
Honored Contributor

Re: Program can not be run in the cron environment

>dmcutil is invoked by dmcManage.sh. However, there is a little difference, when executed in the above script, no rc=137 was reported.

If you expect an output from your script, it should have been sent to the user as an email. (Unless STDOUT/STDERR was redirected to a file)
****
Unix operates with beer.
Kapil Jha
Honored Contributor

Re: Program can not be run in the cron environment

2 things

1) what does /tmp/test.log says now.
2) try
/usr/bin/sh /path/to/dmcutil 1>/tmp/stdout 2>/tmp/stderr

and then check what does these 2 files says.

BR,
Kapil+

I am in this small bowl, I wane see the real world......
Satish Chalapati
New Member

Re: Program can not be run in the cron environment

Dear Kang,

Is there any thing to do with .profile?


I have faced this problem when ever environment variables are present in my logic. So i used to call them before the script in the crontab and it used to get executed.

for e.g one of the issues i have faced is with oracle programs. Then i have set the environment variable of ORACLE_HOME in the script and it worked..
arking1981
Frequent Advisor

Re: Program can not be run in the cron environment

Dear Sooraj Cleris,Dennis Handly,Kapil Jha and everyone:

Yes you are right, it is made by the different environment. The LD_LIBRARY_PATH is not set:
/usr/lib/pa20_64/dld.sl: Unable to find library 'libCDR_pa64-hpux.0'.

Can you please kindly tell me how to set the environment in a cron job?

Thanks in advance.
Kang
Hello world...
arking1981
Frequent Advisor

Re: Program can not be run in the cron environment

Dear everyone,

I am asking if there is a way to import all env from the parent environment.
I hope I don't have to use many set command in the script. I am not lazy but afraid I wll miss something.

Best Regards
Xie Kang
Hello world...
James R. Ferguson
Acclaimed Contributor
Solution

Re: Program can not be run in the cron environment

Hi Kang:

> Can you please kindly tell me how to set the environment in a cron job?

If you profile contains the necessary environmental variables, you can "source" (read) that as the first step of your crontask. A common problem with using the profile, however, is that the standand HP-UX '${HOME}/.profile' contains terminal interactive commands like 'stty' and 'tset'. Since a cron'ed task isn't interactive (associated with a terminal) unless you condition-out this profile code, you get messages of "Not a typewritter" when you cron your task.

A very clean way to handle environmental variables that you want to use in scripts, is to create a separate file of them that you can be "sourced" (read) whenever necessary. By example, you could do:

# cat /home/arking1981/env
#!/usr/bin/sh
export PATH=$PATH:/home/arking1981/scripts
export SHLIB_PATH=/home/arking/1981
export TZ=UTC

To use this, do:

. /home/arking1981/env

...Note the dot character (".") followed by a space (blank) followed the absolute path of the file you want to read "into" your script. This is what is called "sourcing" a file.

# . /home/arking1981/env; /home/arking1981/scripts/dmcutil

...or in a crontab:

5 * * * * ./home/arking1981/env;/home/arking1981/scripts/dmcutil >> /tmp/test.log

The file of your variables can also be sourced at the end of your login profile too. Thus, only ONE copy of variables needs to be maintained.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Program can not be run in the cron environment

>JRF: #!/usr/bin/sh

No need for this in script fragments that you can only source. (Unless this helps your editor.)
James R. Ferguson
Acclaimed Contributor

Re: Program can not be run in the cron environment

Hi:

> Dennis: >JRF: #!/usr/bin/sh
No need for this in script fragments that you can only source. (Unless this helps your editor.)

True. My personal preference is to include the interpreter line as documentation. Of course, in fairness, I only use POSIX or Korn shells so the syntax of the included material should be compatible in either case ;-)

Regards!

...JRF...