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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell script not running properly under cron job

Status
Not open for further replies.

lamqvo

Programmer
Apr 20, 2004
2
US
Hello everyone,

I have a little script:

#!/usr/bin/sh

ssh -l username hostname /usr/bin/cat /Logger/Logger.log > lam.out


What this one does is that it cat a file from the host "hostname" and append to the new file "lam.out" under the current host.

If I run this script normally, it is running fine without any problem.

If I set up a cron job for this script, then it does not run properly.

Anyone know what is wrong with this script?

PS. I have no problem with ssh.
 
Hi:

Whenever a script runs from the command line and doesn't from cron, it's typically a PATH issue. Include a PATH definition in your script, and it'll probably work OK.

Regards,


Ed
 
it's either a PATH issue, or in the case of ssh 'cron' does not have your 'public/private' keys visiable to it when you run the same from command line.



vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Hi,

but sometimes it is because missing Variables, which are set in the users .profile. If you find out which variable are neccesary to set, than set them at the beginning of the script by export XYZ=.....
Cron won't start any .profile by default, so this happen very often.

rgds
 
Thanks Everyone!

After setting the PATH, everything seems running fine!

Best Regards,
Lam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top