Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    how to push a file to multiple locations

    I have a dedi server so I can write scripts as root and run cron jobs, or use cli as root.

    pretty standard web hosting structure, each account is a username as:


    with public_html being the document root for their website

    most of them (but an indeterminite and changing number) will have a file as follows:


    due to permissions, I have this file replicated on each of these websites; but from time to time I make changes to this or other files. I would like to "push" the newer version of imgreader.php in one folder to all other folders, dynamically. So I would want to write a routine I guess with a command like:

    [/home/main/public_html/images]# push imgreader.php

    this would then do just that; copy or replace imgreader.php to each /home/*/public_html/images folder and overwrite if found, BUT give it the permissions of its parent folder.

    Can someone help me with this? Or is there a simpler command already built into Linux? Thanks - and by the way it'd be great to update a bunch of files like *.JPG or a folder like /icons with this command also.


  2. #2
    Linux Engineer
    Join Date
    Jan 2005
    Saint Paul, MN
    The easiest method is to create a group such as "webdevcommon" and include all the users that are allowed to change the source. Put the source in say:
    Then use symbolic links to the above in all the current "imgreader.php" locations. Then you can test one instance by changing its link to point to "in_dev_imgreader.php" rather than "imgreader.php" if changes need to be tested in the the complete environment. Or simply change "imgreader.php" and test outside. When the new version of "in_dev_imgreader.php" is ready copy it into "imgreader.php" (remembering to change the symbolic link back to "imgreader.php" if needed.

    Please note this should work as the user for the file usually is the username for theweb server so it still accesses the file correctly.

Posting Permissions

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