Problem with crontab

Discussion in 'Server Operation' started by biljanapp, Sep 5, 2008.

  1. biljanapp

    biljanapp New Member

    I have sh script which generate doxygen html files.

    #!/bin/sh
    cd /myfile
    doxygen ./Doxyfile


    I try to run script with crontab

    10 10 * * * sh /scripts/doxy.sh


    The problem is that on my virtual machine run just fine but on my server don't run.

    If I try to execute the script manually it run.

    I don't figure out what is wrong???

    Regards Biljana
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Please use the full path to doxygen in your script (e.g. /usr/bin/doxygen instead of just doxygen).

    Alternatively, you could add a PATH variable to your script, e.g.

    Code:
    #!/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    cd /myfile
    doxygen ./Doxyfile
     
  3. ralic

    ralic New Member

    Check your log files for hints on any errors that might be happening and check your mailbox also as cron often emails the user when jobs fail. Also, do you use the same OS on both? There are some differences.

    e.g. My /etc/crontab (on ubuntu) has a username field:
    Code:
    # m h dom mon dow user  command
    So your crontab entry:
    Code:
    10 10 * * * sh /scripts/doxy.sh
    probably wouldn't work on ubuntu unless you had a user "sh" and /scripts/doxy.sh was +x

    Further to what Falko mentioned previously, it would be good practice to include the full path to the shell in the crontab entry:
    Code:
    /bin/sh /scripts/doxy.sh
    That way you'll be sure that the script is executed by the correct sh.
     
  4. biljanapp

    biljanapp New Member

    Thanks for sugestion to check my log file.
    I notice some warnings there.
    I fix the warnings and now it's work just fine.

    Thank you
     

Share This Page