I'm by no means a Solaris expert, but it looks like you are falling for the "cron error number 1": cronjobs have no environment, as they inherit from init and init is notoriously poor. ;-))
When you log on to a system your environment is set (by $HOME/.profile, $HOME/.kshrc, etc.) and all the jobs you start from there will inherit this environment. If you let cron start a job it will inherit the environment from cron, which itself has inherited its from init - and this is (next to) empty. "Normal" commodities like set PATH-variables, etc. are a not there and chances are the commands you use in your script are simply not found.
First I'd like to say that raman1605 is correct: maybe your and the cronjobs rights are different and that the script is able to read/write to/from some logfiles doesn't mean the cron-job is able to do the same. That doesn't *need* to be a problem, but it could very well be one.
Quote:
Originally Posted by rameek20
Is there anything more that cron is supposed to have in the PATH to set?
I have no idea. The best thing you can do to analyze that is to take a snapshot of your own environment by issuing
env > env.file
and look what stands there. Then put into your script everything from there that you think might be necessary, try it again, if it fails add some more, etc., until your script is running.
It is a good idea, though, to create a "standard-function" which sets your scripts environment. You can use this funtion over and over again for all your scripts and if something is missing there you could modify it and all your scripts will benefit. This could look like:
Hi,
I'm unable to understand why the grep command in cronjob works intermittently
Expected output:
Grep command to look for a particular string with today's date and exit from infinite while loop else it must sleep for 5 mins
I'm using the following statement in my shell script, the... (9 Replies)
Hello gurus,
I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired
report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup
is shown below:
#!/bin/ksh
db2... (3 Replies)
hi guys
i have a question
my cron should start executing minute but it sould stop execute only i have tried tis
10 * * * * /home/sample.sh >>
/data/band/cron_$(date+|%Y|m|d).log (2 Replies)
Good evening, ive got this cron to be run:
if i run this manually it doesnt work,it takes me to the prompt again
/export/app/CO/opge/scr/Informe_parametros_colombia.ksh >/dev/null 2>&1
here is the code fragment:
coopge@coopge: opge PRODUCCION>more... (1 Reply)
I am new to creating crontab file , i just wrote below
(40 19 * 3 * /root/maths/practisecron.sh), the script just prints "Hi".
When ever i save the above file i am getting this .
# crontab -e
crontab: installing new crontab
Can you please check where it went wrong.. (1 Reply)
Hi,
I have written a shell script to transfer files to a SFTP server passing the filername, source and dest directory as parameters and it runs well. :)
I want to schedule this script to run periodically using a cron job.
root@pingu # cat /etc/crontab
SHELL=/bin/bash... (1 Reply)
Guys,
I am beginer in unix. There is a cobol file with fixed-width. I want to read the total Line, Word and character count. I have tried with wc-l unix command, but it returns '0'.
Please advice me the correct command/steps to get the record count.
Thanks in advance. (4 Replies)
Hi all!!
I have a nerve-wracking concept (probably for me!!) which is not understood. My crontab entry looks this way.
33 09 22 3 * /home/myexp.sh "Bgp4 ALL" >/dev/null 2>&1
But cron gets started occasionally. Sometimes it does. Sometimes it does not. And sometimes it hangs in the middle (I... (1 Reply)
how to store a date into file?
and how we can access date from the file?
---------- Post updated at 06:09 AM ---------- Previous update was at 06:08 AM ----------
how we can store date in file? (1 Reply)
Below is a simple script that will find the path were the perl command reside.
=========================
#!/usr/bin/sh
nPerl=`which perl 2>>/dev/null|grep -v "no perl"`
if ; then
echo "No Perl application exist..."
else
echo "Existing at $nPerl"
fi
=========================
When I... (2 Replies)