How do I create a script for multiple cronjobs 00 10, 01 11, 02 12...

Discussion in 'Programming' started by NicknameJustin, Mar 13, 2008.

  1. #1
    Hello clever guys and girls out there,

    My server gets overloaded (2 GIG of RAM) because there are 100+ cronjobs that starts every second minute. My Host said that the solution would be to put the cronjobs in a cycle instead, and change the time to every 10th minute instead. So 10 cronjobs will start at the minute: 00, 10, 20 and so on. Next 10 cronjobs will start at the minute: 01, 11, 21 and so on. What would that script look like? My dedicated server has Linux (Debian 4.0) installed. Below is the cron that should run:

     */2 * * * * /usr/local/bin/php -q /web/sites/username/domain1.com/st/admin/cron.php -server 1 > /dev/null 2>&1
    * * * * * /usr/bin/nice /usr/local/bin/php -q /web/sites/username/domain1.com/st/admin/autocrop.php > /dev/null 2>&1
    * * * * * /usr/bin/nice /usr/local/bin/php -q /web/sites/username/domain1.com/st/admin/check.php > /dev/null 2>&1
    
     */2 * * * * /usr/local/bin/php -q /web/sites/username/domain2.com/st/admin/cron.php -server 1 > /dev/null 2>&1
    * * * * * /usr/bin/nice /usr/local/bin/php -q /web/sites/username/domain2.com/st/admin/autocrop.php > /dev/null 2>&1
    * * * * * /usr/bin/nice /usr/local/bin/php -q /web/sites/username/domain2.com/st/admin/check.php > /dev/null 2>&1
    
    */2 * * * * /usr/local/bin/php -q /web/sites/username/domain3.com/st/admin/cron.php -server 1 > /dev/null 2>&1
    * * * * * /usr/bin/nice /usr/local/bin/php -q /web/sites/username/domain3.com/st/admin/autocrop.php > /dev/null 2>&1
    * * * * * /usr/bin/nice /usr/local/bin/php -q /web/sites/username/domain3.com/st/admin/check.php > /dev/null 2>&1
    Code (markup):
    Thanks a lot in advance!
    Justin.
     
    NicknameJustin, Mar 13, 2008 IP
  2. tobiaseichner

    tobiaseichner Peon

    Messages:
    33
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How about simply change scheduling of the cron jobs ? Any script would do nothing else than this ;-)

    Or have I misunderstood your intention ?
     
    tobiaseichner, Mar 13, 2008 IP
  3. NicknameJustin

    NicknameJustin Active Member

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #3
    Thanks for your reply tobiaseichner!

    I'm not soo god at this: I'm just a carpenter :-D
    How do I do that? Change the "2>&1" at the end or change " */2 * * * * /" in the start?
    Can you paste an example of these cronjobs modified into desired cycles that I mentioned first: 00 10, 01 11, 02 12:

    I have a full managed dedicated server, so I email these 3-row cron settings to the support, and they add it. I wish that it was self-managed. I asked them to change the cronjobs into cycles and they answered: "Unfortunately, we do not do programming for customers and I'm not really sure who to send you to."

    Thanks again,
    Justin.
     
    NicknameJustin, Mar 13, 2008 IP