The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Time between CRON jobs (is 20 seconds ok?)

Discussion in 'General Discussion' started by Phree, Jun 16, 2006.

  1. Phree

    Phree Member

    Joined:
    Nov 17, 2005
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    South Coast of England
    Hi all,

    I have a couple of php scripts that I need to run via CRON. I have them running fine and currently running every 15 minutes. I'll quickly explain what they do:

    One of them monitors an email address. If it finds an email with an image attached, it stores it in a specific folder;
    Second one checks that specific folder and then moves & renames the image to a naming convention I need, to another folder.

    Now it's a long story (which I won't bore you with) why I need both scripts running. Trouble is, if more than one image is emailed in in between the jobs running, when they run, the first job does what is should, but then the second job only picks up the first image and then deletes anymore images.

    So that's what the jobs do...My questions are:

    Would it be ok to run these jobs say every 20 seconds? - Would it hammer my server too much?

    I'm thinking of modifying the jobs to loop 4 times every 20 seconds and then just setting the CRON to be every minute...Would that be a better way?

    Thanks for any help/advice.
     
  2. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    Only way to know for sure would be to try it, but it might make more sense to fix the scripts to deal with multiple cases.

    I have a script that runs every minute and does its job 3 times and it doesn't use any noticable power. It would depend on the script and the size of files it has to work with.
     
  3. Phree

    Phree Member

    Joined:
    Nov 17, 2005
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    South Coast of England
    Hi Mike,

    thanks for your reply :D I have to say, I tend to agree with what you say about fixing the scripts! However, in the short term, I think I may just give the 20 second CRON a go!

    Thanks again.
     
  4. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    If you have it loop every 20 seconds, make it only 3 times, otherwise a 4th time will be the same time the script is called again, causing it to run twice at the same time.
     
  5. Phree

    Phree Member

    Joined:
    Nov 17, 2005
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    South Coast of England
    Cheers - will do :)
     
Loading...

Share This Page