Cron not working

Discussion in 'Site & Server Administration' started by mbaldwin, Jan 5, 2010.

  1. #1
    Hi,
    I am having issues with my cron jobs not running on my VPS, running Cent OS 5.4 and Kloxo. The log shows the cron jobs are running, but there is no output from the jobs that should have it. it is not sending me the email either about the jobs when they run, like I set it up to do. If I run the command directly from my SSH client, it works like it is suppose to. any ideas of things to check?

    Thanks,
    michael
     
    mbaldwin, Jan 5, 2010 IP
  2. tamer1009

    tamer1009 Peon

    Messages:
    74
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    do you have Qmail service running?
     
    tamer1009, Jan 5, 2010 IP
  3. mbaldwin

    mbaldwin Active Member

    Messages:
    215
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    95
    #3
    yes, i do believe so.
     
    mbaldwin, Jan 5, 2010 IP
  4. tamer1009

    tamer1009 Peon

    Messages:
    74
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hmmm, strange. i don't have an answer for you :p
     
    tamer1009, Jan 5, 2010 IP
  5. mbaldwin

    mbaldwin Active Member

    Messages:
    215
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    95
    #5
    i just had it email me, cause I wanted to make sure it was working, but the cron jobs are not working. So, the fact it does not e-mail is okay, I guess. I just want it to run my cron jobs. I checked the cron denied user list, and it is blank, so i should be able to run cron jobs as an admin.
    I have one job set to run every 5 minutes, and one to run once a day, and none are working.

    michael
     
    mbaldwin, Jan 5, 2010 IP
  6. Adraco

    Adraco Active Member

    Messages:
    479
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #6
    What host are you on? Can they maybe assist you?
     
    Adraco, Jan 6, 2010 IP
  7. mbaldwin

    mbaldwin Active Member

    Messages:
    215
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    95
    #7
    I am on an unmanaged VPS, so I am on my own.
    Thanks,
    Michael
     
    mbaldwin, Jan 6, 2010 IP
  8. ATTRACTI

    ATTRACTI Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Try on simpler tasks. Add task "echo test > /home/username/test.txt" on every minute. Check if file created in a minute. If simple task work than problem not in cron. If its not work check if crond is running - ps ax | grep cron should print smth like "PID ? Ss 3:02 /usr/sbin/cron"
     
    ATTRACTI, Jan 8, 2010 IP
  9. mbaldwin

    mbaldwin Active Member

    Messages:
    215
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    95
    #9
    Thanks, I setup the test command, and there is no output to a file, and no file has been created. I did the other command from my SSH client, and got
    18135 pts/0 S+ 0:00 grep cron
    32575 ? Ss 0:01crond

    I checked the cron log in /var/log/cron, and there are lines that read
    Jan 8 20:31:01 servermi crond[24544]: (admin) CMD (echo test > /home/admin/test/txt)
    Jan 8 20:32:01 servermi crond[26404]: (admin) CMD (echo test > /home/admin/test/txt)
    Jan 8 20:33:01 servermi crond[5123]: (admin) CMD (echo test > /home/admin/test/txt)
    Jan 8 20:34:01 servermi crond[7244]: (admin) CMD (echo test > /home/admin/test/txt)

    Thanks,
    Michael
     
    mbaldwin, Jan 8, 2010 IP
  10. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #10
    Have you checked the cron log for errors?
     
    RHS-Chris, Jan 8, 2010 IP
  11. mbaldwin

    mbaldwin Active Member

    Messages:
    215
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    95
    #11
    I just double checked several hundred lines of the cron log, and there were no errors, it is jus showing the commands that it is suppose to be running, but that are not getting ran. I can run the exact command for my ssh client, and it works fine, and the log shows the cron running it every minute, or 10 minutes, depending on the schedule.

    Thanks,
    Michael
     
    mbaldwin, Jan 8, 2010 IP
  12. thuankkk

    thuankkk Active Member

    Messages:
    503
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    95
    #12
    Hello,

    You can follow this step by step, and see whether it works:
    - Log in with root user using SSH
    - Enter "crontab -e" (no quotes), this will open text INSERT editor to edit your root crontab
    - Press Insert (this will change text editor into insert mode)
    - Enter "* * * * * echo 'test' > /test.txt" (no dbl quotes), then Esc, then :X
    Your crontab has been saved. You can now check whether test.txt is there, and its last modified time is changed every minute.
    If you don't see any change within next minutes, try creating test.txt, then chmod test.txt into 0777.

    I think the problem is your cron jobs aren't run as root. If the instructions above works, create your cron jobs there.
    If it still doesn't work, go /etc/cron.d, create a file, e.g crontab, then Enter
    YOUR_TIME root YOUR_COMMAND
    e.g. * * * * * root echo 'test' > /test.txt

    After done, run "service crond restart" (using SSH or any command line tool).

    Hope it helps :)

    Best regards,
    Nguyen @ SetCronJob.
     
    Last edited: Jan 14, 2010
    thuankkk, Jan 14, 2010 IP
  13. mbaldwin

    mbaldwin Active Member

    Messages:
    215
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    95
    #13
    Thanks, things did work in the root cron, but not the admin cron. But it is all working now. I had to rebuild my VPS do to other issues I was having. Doubt I iwll ever know what was causing it. I know a lot of problems started when i did Yum updates.

    Michael
     
    mbaldwin, Jan 20, 2010 IP