Also, I think some parts of my code don't even work properly. I am sure there are much more elegant solutions to approach my problem. Sshpass -p my_server_y_password ssh -p "my_server_x_password" scp server_y/file/pathĪnd, after this, I should run my script * * 20 * * my_bash_script.sh 5 commands to copy file from one server to another in Linux or Unix Using SFTP to copy file from one server to another Using RSYNC to copy file from one. # somehow check if file from server_x exists (currently I don't know how to do it on a different server) I think that the code should look like (inside my_bash_script.sh) year_month="$(date +'%Y%m')" If the file does not exist, it shouldn't do anything To use the scp command, you will need to have SSH access to the machine that you are copying the file to. The scp command stands for secure copy, and it allows you to copy files between machines in a secure way. I want to get this code to run on 20th of every month and also use the YYYYMM date format for searching the file. There are a few different ways that you can copy a file from one Linux machine to another. Currently I follow the following steps for copying a file from server_x to server_y (Let's suppose I run this code on 20th April 2021 = 202104) sshpass -p "my_server_y_password" ssh -p "my_server_x_password" scp server_y/file/path
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |