cron - not executing all commands in a shell script

cron - not executing all commands in a shell script

Post by Phil Gerringe » Fri, 31 Dec 1999 04:00:00



Are there any "Rules" to be followed when writing scripts for Cron?
Like:  things that cron cannot execute?

Here is my problem:  I created a java file to do some standard FTP
work.  I created a shell script and placed it in /usr/local.  This
shell script logs the date and then does a grep into a file, then the
java program is called that will FTP the created file.  It works just
fine if you execute the script from the command line (as root).  But
when cron runs it, it does the date, does the grep into the file but
will not run the java part.  Here is what I tried:

1:  The shell script is chmod 777.
2:  The class files are chmod 744.
3:  The log files are all 764.
4:  The entry in crontab has the process being run as root which has
the proper path to provide access to needed files.

I will try to pipe the full cron output into the log file tonight.  Is
there anything else that the collective you can possibly suggest?  Any
help you can provide would be greatly appreciated.  Thanks...

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

cron - not executing all commands in a shell script

Post by Art S. Kage » Fri, 31 Dec 1999 04:00:00


Cron scripts do not have much of an environment.  You will have to set up
the path in the script so it can find java, etc.  Normally not much more
than "/bin:/usr/bin:/sbin" is in the PATH.  You also may have to set up any
other environment variables the apps you want the script to run expect to
find.

Art S. Kagel


> Are there any "Rules" to be followed when writing scripts for Cron?
> Like:  things that cron cannot execute?

> Here is my problem:  I created a java file to do some standard FTP
> work.  I created a shell script and placed it in /usr/local.  This
> shell script logs the date and then does a grep into a file, then the
> java program is called that will FTP the created file.  It works just
> fine if you execute the script from the command line (as root).  But
> when cron runs it, it does the date, does the grep into the file but
> will not run the java part.  Here is what I tried:

> 1:  The shell script is chmod 777.
> 2:  The class files are chmod 744.
> 3:  The log files are all 764.
> 4:  The entry in crontab has the process being run as root which has
> the proper path to provide access to needed files.

> I will try to pipe the full cron output into the log file tonight.  Is
> there anything else that the collective you can possibly suggest?  Any
> help you can provide would be greatly appreciated.  Thanks...

> Sent via Deja.com http://www.deja.com/
> Before you buy.