crontab

Hi, there,

Here is the problem: I wrote a shell script for automatically do the file submission. This script runs great when I use command line. However, after I put it in the crontab for certain time runing, the error message I got was "System is not configured properly, unable to proceed". I don't know what's wrong with the crontab. I checked ownership, it is ok! Please help me to solve this. Thanks in advance!

yun

script
____________________________________________________
#!/bin/sh
#

#
var=`echo $2 | sed 's/;/ /g'`
dirs=`echo $1|sed 's/;/ /g'`
pos=0

for f in $var
do

pos2=0;

for dir in $dirs
do
if [ $pos2 = $pos ]; then

echo `date` $dir $f $3 $4 $5 $6 >> /tmp/cv.initd.dump
if [ "$3" = "ADVEXCEPTION" ]
then
/opt/CV/bin/`/opt/CV/etc/script/config`/cv.aeip -p $dir -f $f $4
exit 0
fi
if [ "$f" = "RESADVEXCEPTION" ]
then
/opt/CV/bin/`/opt/CV/etc/script/config`/cv.aeip -r $dir

    exit 0

fi
/opt/CV/bin/`/opt/CV/etc/script/config`/cv.initd $dir $f $3 $4 $5 $6

fi
pos2=`expr $pos2 + 1`
done
pos=`expr $pos + 1`
done

exit 0

Sounds like you have an environment setting problem. What user do you execute the script as? Is this the same as the root user?

Do use the full path in the crontab?

Please post your cron entry as well.

Also, put a line at the end of your crontab like this 2> error.log to capture any error messages.

Post these errors also.

thank you Kelam_Magnus.

my cron tab like
------------------------------------------------------------------------------------
08 01 * * * find /cvdata2/download/image -name "*upi*" -mtime +2 -exec /usr/bin/rm {} \; 2> /dev/null
#
# this makes a automatic submit tcup* files every morning every 20 min.
01,11,36,50 * * * * find /cvdata/download/image/A -name 'tcup*' |awk -F'/' '{print $6}'| xargs -i /opt/CV/etc/script/tcupsbmt /cvdata/download/image/A {} IMGREQ FILE 0x10 > /var/log/tcup.log 2> /var/log/tcup_error.log
----------------------------------------------------------------------------------

I do put the full path there.

the log file I got like
-------------------------------------------------------------------------
more /var/log/tcup.log
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
--------------------------------------------------------------------

also, 2> /var/log/tcup_error.log
have nothing in it.

thanks again!

oh, I forget that I do use root for the crontab. I changed the ownership and group both to the root for the tcupsbmt script.

Thanks!

Does it run correctly now?

Was your problem that you had the ownership:group wrong?

:slight_smile:

no, it still not running, is ther any other way for the set the environment? Could you give me more details? Thanks!

When you run the script from the command line. What user are you? What are the environment variables for that user. Type env at the prompt. It should give you the variables that are set. What is the PATH of the user that you use to exe the script.

What directory is the script in? What are the directory permissions of directory that the script is in?

Put the script in a directory that is in your PATH line /usr/local/bin or /usr/bin.

Let me know.

When you run the script from . What user are you? What are the environment variables for that user. Type env at the prompt. It should give you the variables that are set. What is the PATH of the user that you use to exe the script.

What directory is the script in? What are the directory permissions of directory that the script is in?

Put the script in a directory that is in your PATH line /usr/local/bin or

Let me know
I run the script from the command line use root. PATH=/usr/sbin:/usr/bin
the directory the script in is /export/home/cvaradm/
the permission:
2 -rwxrwxr-x 1 root root 572 Apr 16 17:59 tcupsbmt

I put the script in /usr/bin, after run, it still show the same error message.

do you think any where I need to improve?
thanks!

What happen if you do the following?

1 - create a new script /opt/CV/etc/script/my_tcupsbmt.sh

#!/bin/ksh
. /etc/profile
. /.profile

/usr/bin/find /cvdata/download/image/A -name 'tcup*' \
| awk -F'/' '{print $6}'| xargs -i /opt/CV/etc/script/tcupsbmt \
/cvdata/download/image/A {} IMGREQ FILE 0x10 \ 1>>/var/log/tcup.log 2>>/var/log/tcup_error.log

exit 0

2- chmod 0755 /opt/CV/etc/script/my_tcupsbmt.sh

3- comment the cron job
01,11,36,50 * * * * find /cvdata/download/image/A -name 'tcup*' |awk -F'/' '{print $6}'| xargs -i /opt/CV/etc/script/tcupsbmt /cvdata/download/image/A {} IMGREQ FILE 0x10 > /var/log/tcup.log 2> /var/log/tcup_error.log

4- Add the cron Job
01,11,36,50 * * * * /opt/CV/etc/script/my_tcupsbmt.sh

Is the same message?. Hugo

Thank you hugo. I did exectly the same way you show me. I got the following message:

apcore03(42): more /var/log/tcup_error.log
$ $ $ $ $ $ $ $ $ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > $ $ $ $ $ $ $ $ $ $ $ > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > $ $ $ $ $ $ $ $ $ $ $ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > $ $ $ $ $ $ $ $ $ $ $ > >
> > > > > > > > > > > > > > > > > > > > > > > > > > > $ $ $ $ $ $ $ $ $ $ $ > > > > > > > > > > > > > > > > > > > > > > > > > > > >
> $ $ $ $ $ $ $ $ $ $ $ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > $ $ $ $ $ $ $ $ $ $ $ > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > $ $ $ $ $ $ $ $ $ $ $ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > $ $

apcore03(43): more /var/log/tcup.log
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed
System is not configured properly, unable to proceed

looks like something as it appeared before. Could you give me more help on that?

yun

1- Comment the cron Job

  1. Try the same script whit the following modifications:

#!/bin/ksh

#normally VERBOSE is an environment variable
VERBOSE=Yes

if [ "$VERBOSE" = "Yes" ]
then
set -x
TTY=`tty`
else
TTY=/dev/null
fi

LOG=/var/log/tcup_error.log

. /etc/profile
. /.profile

/usr/bin/find /cvdata/download/image/A -name 'tcup*' \
| awk -F'/' '{print $6}'| while read param
do
cod_ret=0
/opt/CV/etc/script/tcupsbmt /cvdata/download/image/A $param IMGREQ FILE 0x10 |tee -a $LOG 1>>$TTY 2>>&1
cod_ret=$?
echo "When executing the tcupsbmt /cvdata/download/image/A $param IMGREQ FILE 0x10 " |tee -a $LOG 1>>$TTY 2>>&1
echo "the return code was $cod_ret" |tee -a $LOG 1>>$TTY 2>>&1

done

exit 0

3- Add the environment definitions in your script (tcupsbmt) and a set -x
---------------
. /etc/profile
. /.profile
set -x

4- Try the script from the command line an if OK, uncomment the cron Job.

Note: If possible see and paste the /tcup_error.log and the last mail message of the root user.

Hi, Hugo,

I tried the script you give me, when I run it on command line, give me the following message:

apcore03(76): my_tcupsbmt.sh
+ + tty
TTY=/dev/pts/41
+ LOG=/var/log/tcup_error.log
+ . /etc/profile
+ trap 2 3
+ export LOGNAME PATH
+ [ dtterm = ]
+ umask 022
+ trap 2 3
+ . /.profile
+ PATH=.:/bin:/usr/bin:/usr/local/bin:/usr/X/bin:/usr/ucb:/pub/public/sparc-sun-solaris2.7/bin:/IA/pub/GNU/sparc-sun-solaris2.7/bin:/opt/ARCHIVE/bin/sparc-sun-solaris2.7:/opt/ARCHIVE/etc/script:/opt/ARCHIVE/etc/script/sqls:/opt/ARCHIVE/etc/script/utils:/opt/ARCHIVE/etc/script/startup:/opt/ARCHIVE/etc/script/shutdown:/opt/ARCHIVE/etc/script/menu:/opt/ARCHIVE/etc/script/perl:/opt/CV/bin/sparc-sun-solaris2.7:/opt/CV/etc/script:/usr/ccs/bin:/usr/sbin:/export/home/cvaradm/bin:/usr/java/lib:/usr/java1.2/bin:/opt/WV/bin/sparc-sun-solaris2.7:/ora00/app/oracle/product/8.0.5/bin:/ora00/app/oracle/admin/scripts:/ora00/app/oracle/product/8.0.5/bin:/opt/ARCHIVE/masterdb/scripts/stat_rep:/usr/dt/bin:/usr/openwin/bin:/bin:/usr/bin:/usr/ucb:/usr/sbin:/usr/opt/SUNWmd/sbin:/usr/bin/nsr
+ EDITOR=vi
+ export PATH EDITOR
my_tcupsbmt.sh[20]: syntax error at line 23 : `&' unexpected

It couldn't execute. Any comments?

yun

The environments in /etc/profile was loaded well, but when
the script try to load the /.profile settings the script fail. I
think that you need to review the /.profile file (near the export PATH declaration).

Another way to try to resolve the problem is to set the environment separately.

1- comment the the linesthe following lines in both scripts:
. /etc/profile
. /.profile

2- if the output of "env |grep -i cv" display lines
insert and export those lines in the .sh (script) following the set -x declaration.

3- Insert the Following to Lines in both scripts
PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/X/bin:/usr/ucb:/pub/public/sparc-sun-solaris2.7/bin:/IA/pub/GNU/sparc-sun-solaris2.7/bin:/opt/ARCHIVE/bin/sparc-sun-solaris2.7:/opt/ARCHIVE/etc/script:/opt/ARCHIVE/etc/script/sqls:/opt/ARCHIVE/etc/script/utils:/opt/ARCHIVE/etc/script/startup:/opt/ARCHIVE/etc/script/shutdown:/opt/ARCHIVE/etc/script/menu:/opt/ARCHIVE/etc/script/perl:/opt/CV/bin/sparc-sun-solaris2.7:/opt/CV/etc/script:/usr/ccs/bin:/usr/sbin:/export/home/cvaradm/bin:/usr/java/lib:/usr/java1.2/bin:/opt/WV/bin/sparc-sun-solaris2.7:/ora00/app/oracle/product/8.0.5/bin:/ora00/app/oracle/admin/scripts:/ora00/app/oracle/product/8.0.5/bin:/opt/ARCHIVE/masterdb/scripts/stat_rep:/usr/dt/bin:/usr/openwin/bin:/bin:/usr/bin:/usr/ucb:/usr/sbin:/usr/opt/SUNWmd/sbin:/usr/bin/nsr

export PATH

(Similar PATH Definition is in the /.profile)

No surrenders, give him it fights that for sure you will win him.

When building a cron script, one of the first steps is to make sure it works from the command line first.

So, the basic question one might ask is,

Thanks, Hugo, Neo,

Firstly, I already mentioned that I run this script very good on command line. That's why I post this why it not run in my crontab.

Secondly, I try the comment from Hugo: I insert the Path into my script, It shows:

apcore03(60): my_tcupsbmt.sh
+ PATH=.:/bin:/usr/bin:/usr/local/bin:/usr/X/bin:/usr/ucb:/pub/public/sparc-sun-solaris2.7/bin:/IA/pub/GNU/sparc-sun-solaris2.7/bin:/opt/ARCHIVE/bin/sparc-sun-solaris2.7:/opt/ARCHIVE/etc/script:/opt/ARCHIVE/etc/script/sqls:/opt/ARCHIVE/etc/script/utils:/opt/ARCHIVE/etc/script/startup:/opt/ARCHIVE/etc/script/shutdown:/opt/ARCHIVE/etc/script/menu:/opt/ARCHIVE/etc/script/perl:/opt/CV/bin/sparc-sun-solaris2.7:/opt/CV/etc/script:/usr/ccs/bin:/usr/sbin:/export/home/cvaradm/bin:/usr/java/lib:/usr/java1.2/bin:/opt/WV/bin/sparc-sun-solaris2.7:/ora00/app/oracle/product/8.0.5/bin:/ora00/app/oracle/admin/scripts:/ora00/app/oracle/product/8.0.5/bin:/opt/ARCHIVE/masterdb/scripts/stat_rep:/bin:/usr/bin:/usr/local/bin:/usr/X/bin:/usr/ucb:/pub/public/sparc-sun-solaris2.7/bin:/IA/pub/GNU/sparc-sun-solaris2.7/bin:/opt/ARCHIVE/bin/sparc-sun-solaris2.7:/opt/ARCHIVE/etc/script:/opt/ARCHIVE/etc/script/sqls:/opt/ARCHIVE/etc/script/utils:/opt/ARCHIVE/etc/script/startup:/opt/ARCHIVE/etc/script/shutdown:/opt/ARCHIVE/etc/script/menu:/opt/ARCHIVE/etc/script/perl:/opt/CV/bin/sparc-sun-solaris2.7:/opt/CV/etc/script:/usr/ccs/bin:/usr/sbin:/export/home/cvaradm/bin:/usr/java/lib:/usr/java1.2/bin:/opt/WV/bin/sparc-sun-solaris2.7:/ora00/app/oracle/product/8.0.5/bin:/ora00/app/oracle/admin/scripts:/ora00/app/oracle/product/8.0.5/bin:/opt/ARCHIVE/masterdb/scripts/stat_rep:/usr/dt/bin:/usr/openwin/bin:/bin:/usr/bin:/usr/ucb:/usr/sbin:/usr/opt/SUNWmd/sbin:/usr/bin/nsr
+ export PATH
+ + tty
TTY=/dev/pts/3
+ LOG=/var/log/tcup_error.log
my_tcupsbmt.sh[25]: syntax error at line 28 : `&' unexpected

I may try to revise the script. Any more suggestions please let me know.

Thanks Hugo!

yun

If you use copy-paste from the web,

  • make sure that a line was not unwittingly splitted.
    (in the big lines use the $ to go to the end of the line)

If it's necessary use "Shift j" to lift the rest of the line.

Note:

In the following line

/opt/CV/etc/script/tcupsbmt /cvdata/download/image/A $param IMGREQ FILE 0x10 |tee -a $LOG 1>>$TTY 2>>&1

to capture the correct error code You must to delete
|tee -a $LOG 1>>$TTY 2>&1

because actually, capture the value from the tee.

Sorry. Hugo.

If the script works from the command line... my suggestion is to just simply put the entire path of all the commands in the script so you don't have to worry about environmental variables... this also makes the script easier to debug.

For example, in our scripts, we don't use chmod, we use /bin/chmod and so forth for all commands and paths.......

... you might find that a similar approach in your cron scripts makes life a bit easier ....

Hi, there,

I find that the script cann't run on crontab is because I use one of the C program cv.initd in the script. Is there any suggestions on how to run this C program on crontab?

Yun

Please paste the logfile of the script. Thanks. Hugo.