• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

shell script not running as cron

 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"./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").
 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. why did i think it would be relative to the parent script!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic