Results 1 to 5 of 5

Thread: How to create a cron job to copy folders

  1. #1
    Join Date
    Mar 2010
    Posts
    18

    Default How to create a cron job to copy folders

    Hi,

    I never created a script for a cron file nor set one up. I need to know how to make a cron file and have it copy any new folders and files in those folders from one site to another site on the same hosting account. This is to keep two sites in sync.

    Thanks,

    Gibs

  2. #2
    Join Date
    Nov 2006
    Location
    Sydney, Australia
    Posts
    4,951

    Default

    Go into the cron option in cPanel.

    In there you will need to enter the options to specify both when the cron is to run and what it is to run.

    Note that path references in cron are from two folders above public_html so you need to include the home folder and account name folder on the front of any paths.

  3. #3
    Join Date
    Mar 2010
    Posts
    18

    Default example

    Hi,

    Thanks for the reply. Do you have an example I can go by?

    So i need to create a script? And if so save it as what type of file? Could you give me a few lines to go by or a reference where examples are?

    Thanks,

    Gibs

  4. #4

    Default cp -ur

    WARNING: FOLLOWING THESE INSTRUCTIONS WILL RESULT IN REPLACING OLDER FILES IN THE TARGET DIRECTORY. IF YOU WANT TO KEEP OLDER FILES, DON'T DO THIS.

    To create a cron job that copies newer files from one directory to another do the following:
    1. go to cPanel and type "cron" in the find box.
    2. select the "Cron jobs" icon from the "Advanced" tool box
    3. select the time or frequency you want the cron to run from the pulldown menus.
    4. in the "Command" text entry field type "cp -urp <site1_dir>/* <site2_dir>"

    If you want the syncronization to occur in both directions create a similar cron for "cp -urp <site2_dir>/* <site1_dir>"
    Promote your website by posting a link at TheWebTitan Forum.
    Then, vote for your favorite website or blog, including maybe yours, at TheWebTitan.com.
    Website with the most votes: Wikipedia.org
    Website with the last vote: Wikipedia.org/wiki/Angels_&_Demons_(film)

  5. #5
    Join Date
    Mar 2010
    Posts
    18

    Smile Thanks

    Hi,

    It worked perfectly. Thank you for your help.


    Gibs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •