I have a number of config files that change a couple of times a month that need to be copied to about 6 EC2 instances. I believe the most efficient way to do this is with a series of scp command in a batch file stored on a windows pc, for example: sudo scp -i "C:\cygwin64\home\Ken\ken-key-pair.pem" \Users\Ken\testcyg2.txt [email protected]:/var/www/html/folder-owned-by-ec2-user/testcyg2.txt
This command works, as long as the owner of the folder is ec2-user. My question is how copy the files to folders owned by the "root" user.
I am not sure this is possible using the aws cli, so I thought I should use the command above, and then a cronjob to take the files from the folder owned by ec2-user, and copy them to a folder owned by the root user.
I put the following command in a crontab, but it does not seem to work: */5 * * * * cp /var/www/html/temp4configs /var/www/html
I even created another crontab using sudo crontab -e, since I was logged in as ec2-user. I do not get any error messages.
Is there a better way to do this, or is there anything I am doing wrong? Thanks!