Skip to main content

Copying files between accounts

Answered

Comments

11 comments

  • cPRex Jurassic Moderator

    Hey there!  There is no way to do this as a cPanel user due to the permissions on the server.  You would have to be the root user in order to perform this action.

    0
  • stevsnet

    Thanks for that. I am the WHM root user. How do I go about enabling this code as the root user?

    0
  • cPRex Jurassic Moderator

    You would need to call that PHP script as root, so a cron job under the root user would work.

    0
  • stevsnet

    Right. How do I call the script as root?

    In account xxxxx I have 
    <-- ?php
    copy('/home/xxxxx/somedirectory/a.zip', '/home/yyyyyy/diffdirectory/a.zip,');
    -->
    What do I need to modify?
    I can log into cpanel from whm as the root user but I'm not sure how that would help.
    Thanks

    0
  • cPRex Jurassic Moderator

    The file likely wouldn't be stored under the account.  It would be best to place this in /root or somewhere else on the server where it isn't limited to one account.

    Then you would create the cron with a command similar to this:

    x x x x x /usr/local/bin/php /full/path/to/your/file.php

    https://support.cpanel.net/hc/en-us/articles/360051846373-Create-a-Root-user-cron-job

    0
  • stevsnet

    I had tried creating zipper.sh and placed it in the root but running a cron job to read it from the account didn't work. It didn't see it. Looking in WHM the only reference to running a cron job doesn't allow for creating a cron job. Just Command: upcp and backup.

    0
  • cPRex Jurassic Moderator

    You wouldn't be able to create the cron job as the user.  Everything has to be done as root.  You'll have to use the steps I linked above on the command line in order to add a new cron.

    0
  • stevsnet

    Thanks. I'm able to add the command in terminal as per those instructions but it doesn't get saved when applying this instruction

    If the editor is "vi," or similar:

    1. Press ESC
    2. Type ":wq"
    3. Press enter

    The cursor moves back a space when I escape, typing .wq creates a copy of the command and appends it to the command. Which I have to then delete. Ctrl+C doesn't save either.

    After typing the command how do I save it. Thanks

    0
  • cPRex Jurassic Moderator

    You want a colon, :, not a period before the wq.

    0
  • stevsnet

    Ahh, thanks. My bad eyes :) That worked

    0
  • cPRex Jurassic Moderator

    Glad to hear it!

    0

Please sign in to leave a comment.