aspose file tools*
The moose likes Linux / UNIX and the fly likes shell script not running as cron Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "shell script not running as cron" Watch "shell script not running as cron" New topic
Author

shell script not running as cron

Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 349

i have one shellscript which does some work and i am trying to invoke another script from within it.

something like this -


when I run this myself, works like a charm. When it is run by the cron seems like script.ksh is not being invoked properly.

Have also tried running it directly instead of using period still no luck.

any clues?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

"./script.ksh" means "the file in the current directory named script.ksh". When you run your script from cron, the current directory is generally going to be your home directory, so unless script.ksh is there, this isn't going to work. There are many ways to deal with this; one simple one would just be to use an absolute path (i.e., like "/home/Srivastava/bin/script.ksh").


[Jess in Action][AskingGoodQuestions]
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 349

thanks. why did i think it would be relative to the parent script!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Abhinav Srivastava:
thanks. why did i think it would be relative to the parent script!


I think Windows works that way... sometimes.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Originally posted by Ernest Friedman-Hill:


I think Windows works that way... sometimes.


I don't think so.

While working on a script, and testing it: ./foo.sh - the location of the script often IS the PWD. That may lead to wrong assumptions.


http://home.arcor.de/hirnstrom/bewerbung
 
 
subject: shell script not running as cron