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.

Need help about cron jobs.

Discussion in 'General Discussion' started by RSA_ASR, Aug 19, 2007.

  1. RSA_ASR

    RSA_ASR Registered

    Joined:
    Aug 19, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hello there.


    I need help with one cron job. I need change every 2 or 3 hours one file. I try explain:


    I have 3 files:

    config.php
    config2.php
    config3.php

    I need rename every file each 2 hours

    config.php => config2.php
    config2.php => config3.php
    config3.php => config.php


    I don't know how can I make it... if only its possible make with 2 files, then no problem, but I need something like this, and I think this is the way to rename files.. :)
     
  2. rentaserv.net

    rentaserv.net Registered

    Joined:
    Aug 19, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Config File

    Hi,

    I believe You Would Have To Make A Main Configuration File to Make these changes thn configure the cron in cpanel to run this action every hour or whatever time frame you want.
     
  3. nerbonne

    nerbonne Well-Known Member

    Joined:
    Aug 19, 2007
    Messages:
    52
    Likes Received:
    1
    Trophy Points:
    6
    Probably better to have three configs, config1, 2, and 3. Then run a cron job every three hours to remove the old link and write a new one to config1. Have three cron jobs on three different hours.
     
  4. bodhost.com

    bodhost.com Active Member

    Joined:
    Aug 8, 2007
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Initially try configuration from cPanel to work it out, if not then you will need to setup the cron on the server. :)
     
  5. eeadmin

    eeadmin Well-Known Member

    Joined:
    Oct 21, 2004
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Dallas, TX
    File names

    Do you just need the file names rotated or do you need the files to execute in that order?
     
  6. DGermancp

    DGermancp Active Member

    Joined:
    Feb 25, 2006
    Messages:
    43
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    NJ, USA
    cPanel Access Level:
    Reseller Owner
    If you have shell access, I think what you want is

    1)make a file /home/$USER/rotatephp.sh

    mv config.php tmp.php
    mv config3.php config.php
    mv config2.php config3.php
    mv tmp.php config.php

    Then

    export YYMMDD=`date +"%y%m%d"` #create a variable to uniquely save current crontab
    crontab -l > crontab.$YYMMDD # list current crontab ( that's an ell not a eye)
    cat > crontab.$YYMMDD <<++ # append what follows to crontab file
    07 0,2,4,6,8,10,12,14,16,18,20,22 * * * /home/$USER/rotatephp.sh
    ++

    crontab crontab.$YYMMDD # install new crontab

    see http://www.real-world-systems.com/docs/crontab.1.html

    Let us know if that's what you need or
    If you do not have shell access
     
  7. bodhost.com

    bodhost.com Active Member

    Joined:
    Aug 8, 2007
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    hmmm...i think that should solve the problem :)
     
Loading...

Share This Page