By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,761 Members | 1,062 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,761 IT Pros & Developers. It's quick & easy.

Crontab problem

P: 39
Hi,

I have jar file which creates some files. This jar file is called/run by shell script. Manually, I run the shell script and jar file creates the files and files' contents successfully.

When I set the cronjob to run the file. It runs the shell script and creates the file but somehow file does not have any content.

Anyone has any idea, why I am missing the contents of the file
(When I run the shell script by cronjob)?
Sep 12 '08 #1
Share this Question
Share on Google+
3 Replies

numberwhun
Expert Mod 2.5K+
P: 3,503
Make sure that the command that you have in cron, to run, is the exact same command you use on the command line (including any options).

Also, you have to remember that when crontab runs, its actually root that is executing it, not the user.

Can you also provide a little more information into what the script is doing and what you aren't seeing?

Thanks!

Regards,

Jeff
Sep 12 '08 #2

P: 39
Thanks to reply,

Yes, I ran the cron as root.

1) My shell script is responsible to run a jar file.
2) This jar file is responsible to create a file and writes some data in the file.

When I manually run the shell script, it runs jar file and I get the file with some data. It is OK.

But when I set cron to run the shell script then jar creates the file only. I don't get any data in the file.
Sep 12 '08 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
Thanks to reply,

Yes, I ran the cron as root.

1) My shell script is responsible to run a jar file.
2) This jar file is responsible to create a file and writes some data in the file.

When I manually run the shell script, it runs jar file and I get the file with some data. It is OK.

But when I set cron to run the shell script then jar creates the file only. I don't get any data in the file.
I think what you need to do is redirect standard error to a log file. Add something like this to the end of the command in your crontab entry:

Expand|Select|Wrap|Line Numbers
  1. 2>error_log.txt
  2.  
Let it run again and check that and see if there are any errors reported. Something has to be causing the data to no get into the file. You need to just figure out what and why.

Regards,

Jeff
Sep 12 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.