Crontab problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kokababu
    New Member
    • Jul 2008
    • 39

    Crontab problem

    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)?
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    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

    Comment

    • kokababu
      New Member
      • Jul 2008
      • 39

      #3
      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.

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        Originally posted by kokababu
        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:

        Code:
        2>error_log.txt
        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

        Comment

        Working...