Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script through - not answered 4

Status
Not open for further replies.

jouell

MIS
Nov 19, 2002
304
US
I've been searching w/o luck


This script:

#!/bin/ksh
cd /dir
DATE="/bin/date"
YEAR=$($DATE +%EY)
MNTH=$($DATE +%m)
DAY=$($DATE +%d)
/usr/bin/echo "$YEAR$MNTH$DAY" > FILE


runs OK except when run in cron (at 10:55 pm)


It fails w/

sh: TT_DB: cannot execute

TT_DB is a directory, why is the shell expanding the script
variable like that? I have used set -o v w/o any luck.....

Thanks
-John




 
Does the owner of the cron job have the permission to do this ?
cd /dir

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yes, the owner is root and is running through root cron.

Thank you for the response.

-John
 
You may try this for debugging:
#!/bin/ksh
set -x
cd /dir
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks I get this interactively :

./yesterday.sh line 8: cd /dir
./yesterday.sh line 9: DATE=/bin/date
./yesterday.sh line 10: ./yesterday.sh line 10: /bin/date +%EY
YEAR=2005
./yesterday.sh line 11: ./yesterday.sh line 11: /bin/date +%m
MNTH=04
./yesterday.sh line 12: ./yesterday.sh line 12: /bin/date +%d
DAY=13
./yesterday.sh line 13: /usr/bin/echo 20050413
./yesterday.sh line 13: 1> /dir/yesterday.txt


and the same error in cron....

Anything else to try?

Thanks
-John
 
Post the relevant crontab line.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
55 22 * * * * /dir/yesterday.sh

OK here you go

Thanks!
-john
 
Why not simply this ?
55 22 * * * * date +\%EY\%m\%d > /dir/FILE 2>/dir/FILE.err

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I get the same error with that!

Thanks I thought that was going to work!


-John

 
Does other cron jobs work without problem ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yes, absolutely. This script fails on another host.
I think the script is the problem, not sure why.

-John
 
Loose one of the asterisks in the crontab! You've got one too many, so cron is expanding the last asterisk to be your command. It's matching that directory.

Hope this helps.
 
If that's the whole script that you posted, you don't really need it at all. Just make the crontab entry read...
Code:
55 22 * * * /bin/date '+EY%m%d' /dir/FILE 2>&1
Same result, less to maintain.

Hope this helps.
 
#!/usr/bin/ksh (or whatever your ksh is)
cd /tmp
DATESTAMP=`date '+%Y%m%d'`
echo $DATESTAMP > FILE


"If you always do what you've always done, you will always be where you've always been."
 
You guys rock, my crontab was wrong! Everyone gets a star, special thanks to SamBones for nailing this exactly and PHV for persistance. I like using DATESTAMP as a variable rzs.

Final script:
FILE=/dir/yesterday.txt
DATESTAMP=`date '+%EY%m%d'`
echo $DATESTAMP > $FILE

crontab:
55 22 * * * /nsr/idx_scripts_dev/yesterday.sh

THANKS!!!!
-john
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top