Cronjob does not run properly - Redhat

This is a discussion on Cronjob does not run properly - Redhat ; Details: home directory - /home/userid 1) 1 perl program - program.pl Takes couple parameters from ARGV and generates 1 output file in the same directory. The program will also generate some stdout to show the progress. I can run it ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Cronjob does not run properly

  1. Cronjob does not run properly

    Details:

    home directory - /home/userid

    1) 1 perl program - program.pl

    Takes couple parameters from ARGV and generates 1 output file in the
    same directory. The program will also generate some stdout to show the
    progress. I can run it with 'perl program.pl variable1 variable 2'. The
    porgress is shown in stdout and the output file is generated.

    2) 1 bash script - script.sh

    echo START `date`
    /usr/bin/perl /home/userid/program.pl variable1 variable2
    echo STOP `date`

    I can run it with '/bin/bash /home/userid/script.sh' in the command
    line, echo statements display, the perl program runs ok with the
    correct output file and the progress is shown in stdout.

    Problem: when I put the script.sh in crontab - 5 12 * * * /bin/bash
    /home/userid/script.sh > /home/userid/log.txt, log.txt is generated.
    However,

    log.txt has the output from the echo START and echo STOP statements but
    not the perl program. I check the time generated by `date` in the echo
    statements and they are the same. The perl program takes about 15 sec
    to run. It seems to me that the perl script was never ran at all.

    Can anyone shed some light on this? I have spent too much time on this
    already.


  2. Re: Cronjob does not run properly

    Pleaes ignore this topic. I found the problem after stop drinking
    coffee - I need to put in 'absolute path' in all the input or output
    file in the program!!!

    jthwong1@gmail.com wrote:
    > Details:
    >
    > home directory - /home/userid
    >
    > 1) 1 perl program - program.pl
    >
    > Takes couple parameters from ARGV and generates 1 output file in the
    > same directory. The program will also generate some stdout to show the
    > progress. I can run it with 'perl program.pl variable1 variable 2'. The
    > porgress is shown in stdout and the output file is generated.
    >
    > 2) 1 bash script - script.sh
    >
    > echo START `date`
    > /usr/bin/perl /home/userid/program.pl variable1 variable2
    > echo STOP `date`
    >
    > I can run it with '/bin/bash /home/userid/script.sh' in the command
    > line, echo statements display, the perl program runs ok with the
    > correct output file and the progress is shown in stdout.
    >
    > Problem: when I put the script.sh in crontab - 5 12 * * * /bin/bash
    > /home/userid/script.sh > /home/userid/log.txt, log.txt is generated.
    > However,
    >
    > log.txt has the output from the echo START and echo STOP statements but
    > not the perl program. I check the time generated by `date` in the echo
    > statements and they are the same. The perl program takes about 15 sec
    > to run. It seems to me that the perl script was never ran at all.
    >
    > Can anyone shed some light on this? I have spent too much time on this
    > already.



+ Reply to Thread