do you execute this script manually with the same user to which this crontab belongs?
Besides this you could try to give the full path to your shell (/bin/sh or /usr/bin/sh?) because depending on your environment configuration the cron scripts don't have the same PATH environment variable you have when executing things interactively.
And it's always a very good idea to take a look at the syslog file on UNIX/Linux systems. At the specified time when the cron job should execute there must be an entry what it does or what went wrong, so just have a look at it
Joined: Jun 04, 2005
Thanks for reply Marco.
I executed script manually with the same user to which this crontab belongs. Script is try to running from user root directoy, even if i have to configure bin/sh. If i am run in solaris environment where can i see specified time is log file is running or not.
Thanks in advance, Thanks and Regards, Abiramkumar.P
As Marco suggests, you should probably be explicit as to which shell you want to run your scripts. From memory, on Solaris scripts will be run by /usr/bin/sh if you do not explicitly specify anything else. While that should be fine in this case, it is easy to be logged in using a different shell (tcsh, csh, ...) and write a viable script that then fails at deploy time in weird ways.
So, even if you are happy with running using the standard shell, I would still recommend your first line be #!/usr/bin/sh just so it is explicit to anyone looking at your code that this is what you wish to use.
Script is try to running from user root directoy,
Correct. By default, all cron and at scripts are run from the home directory of the user who owns the crontab or at entry.
I suspect that if you look in the DebugUpload.log file, you are probably getting a message about the class not being found. I further suspect that the DebugUpload.log file is in the user's home directory (and I bet that is not where you expected it)
So that then gives a likely fix: Around line 2 or 3 of your script, change to the directory where you really want the script to run. Something like:
If you are still having troubles, then please tell the details of the errors. There should be something in the DebugUpload.log that will show what the error is.
Speaking of the DebugUpload.log file - instead of creating that in the script you are running, why not create it in the crontab entry (and give it a fully qualified path). At the moment I am betting on this file being in the user's home directory, but I am not sure. If the log file was specified using a fully qualified path then we would know where the file was. Likewise, if the log file was being created from the crontab entry then you would also see any errors in the cron running or any errors in the script that were external to Java.
if you give an explicit shell when executing your script like with "/bin/sh skriptname.sh" it works even without including the interpreter in the script. So for you crontab it should even work without the #!/bin/sh or #!/usr/bin/sh.
As Andrew already said the problem is surely either that cron doesn't find your shell in its path or that you are in the wrong directory when the script is executed. But this should show up in the system logs or in the log generated by your script. There must be some error message at the time the cron job runs.
1. Add the "shebang" to the script. I think "#!/bin/sh" is pretty universal - often linked to /usr/bin/sh, though WHICH shell you get may be unpredictable. The default one in Solaris is the dumb one. If you need a specific shell, use its absolute path.
2. Make sure that the script is marked as executable. This is CRITICAL!
3. When using selinux, make sure that the SE attributes are suitable for cron.
You should now be able to remove the "sh" command from your crontable entry and actually this is better, since if your script needed a specific shell such as csh or ksh, the script itself would be able to ensure it was used.
In Solaris, check the /var/adm directory for log info. /var/log doesn't always have what you need.
An IDE is no substitute for an Intelligent Developer.
Joined: Jun 04, 2005
Thanks for all replys!!!
Still i have a problem in production server.I have an one doubt,Please clarrify.
I think, this could make you trouble. As you only export your CLASSPATH and JAVA_HOME variable chances are good that this interferes with other settings in your system at runtime. Better use the variables explicitly, for example:
Hope this helps. At the moment I don't see any other issues. Doesn't your log file show any hints?
Joined: Jun 04, 2005
Thanks for all you reply.
Finally i solved this issue.My boss asked to put the following code in my sh file.
Now it is working fine. This path is copied from user profile.