Operating System - HP-UX
1833875 Members
2915 Online
110063 Solutions
New Discussion

Re: problem with shell-script and cron

 
SOLVED
Go to solution
Oliver Charni
Trusted Contributor

problem with shell-script and cron

I recently tried to schedule a shell-script(Script see attachment) using cron to run each day at 8am, but the only thing it produces are the following errors(for explaination the script uses a C-Programm called oliver to calculate a Timespan):
/home/oliver/reportomni.sh[47]: omnidb: not found.
/home/oliver/reportomni.sh[3]: omnidb: not found.
/home/oliver/reportomni.sh[10]: omnidb: not found.
/home/oliver/reportomni.sh[12]: omnidb: not found.
/home/oliver/reportomni.sh[13]: omnidb: not found.
arg1 Getdate(3C) exit code 7: There is no line in the template that matches the input
/home/oliver/reportomni.sh[50]: omnidb: not found.
/home/oliver/reportomni.sh[3]: omnidb: not found.
/home/oliver/reportomni.sh[10]: omnidb: not found.
/home/oliver/reportomni.sh[12]: omnidb: not found.
/home/oliver/reportomni.sh[13]: omnidb: not found.
arg1 Getdate(3C) exit code 7: There is no line in the template that matches the input
/home/oliver/reportomni.sh[53]: omnidb: not found.
/home/oliver/reportomni.sh[3]: omnidb: not found.
/home/oliver/reportomni.sh[10]: omnidb: not found.
/home/oliver/reportomni.sh[12]: omnidb: not found.
/home/oliver/reportomni.sh[13]: omnidb: not found.
arg1 Getdate(3C) exit code 7: There is no line in the template that matches the input


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

/home/oliver/reportomni.sh >/home/oliver/reportomni.log

It also doesnt write the log as it is supposed to. The Entries in the crontab are:

50 7 * * * /home/oliver/movelogs.sh >>/home/oliver/reportomni.log
0 8 * * * /home/oliver/reportomni.sh >>/home/oliver/reportomni.log

Can Anybody help me.
if it smell's funny on the outside, it's worse on the inside
3 REPLIES 3
Stefan Farrelly
Honored Contributor
Solution

Re: problem with shell-script and cron


When you run scripts under cron your normal PATH environmental variable is not set the same as when you log in using a shell, so in your cron script set PATH to exactly what you need. eg, at a minimum PATH=$(cat /etc/PATH)
and add on any application directories you need, eg, /opt/omni/bin or whatever.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Tom Danzig
Honored Contributor

Re: problem with shell-script and cron

As Stefan says, in cron, the path defaults to /usr/bin:/usr/sbin. Add this to the start of your script:

export PATH=$PATH:/opt/omni/bin:/opt/omni/sbin

This assumes this is the correct (default) path to the omnidb commands.
Pete Randall
Outstanding Contributor

Re: problem with shell-script and cron

Oliver,

As a general rule, I code full path names in my shell scripts so this type of problem is avoided. For example /opt/omni/bin/omnidb rather than omnidb.

Good luck,
Pete

Pete