cron job issue

Discussion in 'Site & Server Administration' started by rahuldas14, Feb 15, 2010.

  1. #1
    I set this up in the cron tab.

    [​IMG]

    I want this to run every 5 mins. It is supposed to mail me. When I execute it
    sh load_check.sh
    it works fine and mails me.
    But I am not receiving any mails so i think it is not working. Please help me
     
    rahuldas14, Feb 15, 2010 IP
  2. FavouritesBlog

    FavouritesBlog Peon

    Messages:
    846
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ok, this doesn't make any sense.

    " it works fine and mails me "

    But your not receiving the mails? so you dont think its working?
     
    FavouritesBlog, Feb 15, 2010 IP
  3. fierceservers

    fierceservers Peon

    Messages:
    338
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Why don't you just do this:
    At the top of the crontab file, include:
    The results should be e-mailed to you and you could remove the mailing function of your script.
     
    fierceservers, Feb 15, 2010 IP
  4. thuankkk

    thuankkk Active Member

    Messages:
    503
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    95
    #4
    Hi rahuldas14,

    According to your info, when you run your script manually, it works and mails you;
    but when you set up cron jobs, it doesn't work and you don't receive any mail, right?

    Here's something to try:
    - Is crond running? run this
    service crond restart
    Code (markup):
    - Where do you set up your cron?
    If you set up cron using crontab -e command, remove "root"
    */5 * * * * command_goes_here
    - Did you add the she-bang at beginning of your script?
    add this:
    #!/bin/sh
    Code (markup):
    - Does your script have executing permission?
    chmod 0777 your file.


    Or you can try this step by step:
    - enter crontab -e to open crontab file.
    - add this cron:
    */5 * * * *  /bin/sh /usr/local/bin/load_check.sh
    Code (markup):
    (Do a "whereis sh" and check where your sh is. Mine at /bin/sh; some at /usr/bin/sh).

    Hope it helps :)

    Best regards,
    Nguyen An Thuan.
     
    thuankkk, Feb 15, 2010 IP
  5. rahuldas14

    rahuldas14 Well-Known Member

    Messages:
    679
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    130
    #5
    Sorry guys I forgot to chmod it. :)
     
    rahuldas14, Feb 18, 2010 IP