Javascript required
Skip to content Skip to sidebar Skip to footer

How to Upload a Python File to an Ec2 Instance

Running Python scripts on an AWS EC2 Example

AWS EC2 Case on Putty
          cd /usr/bin/
ls
  1. You will probably see python two.7 already installed which is the older version, so let's go ahead and install python 3.half dozen
          sudo yum install python36        
          alternatives --ready python /usr/bin/python3.6          python --version        
          cd /tmp
curlicue -O https://bootstrap.pypa.io/go-pip.py
python3 get-pip.py --user
pip3 --version
          pip3 install selenium --user        
  1. First open a windows terminal on your auto using cmd.
  2. Use scp (Secure Copy Protocol) to transfer files between the local and the remote host. The scp command has iii arguments, the first statement is the file path to the private key ".pem" file, the 2d argument is the path to the location of the file you want to copy from your machine, and the third argument is the path to the location on the example where you desire to re-create it.
          scp -i path/to/.pem_file path/to/file   username@host_address.amazonaws.com:/path_to_copy        
          scp -i D:/ec2/examination.pem D:/ec2/exam.py ec2-user@ec2-eighteen-191-31-0.us-eastward-2.compute.amazonaws.com:/dwelling house/ec2-user        
  1. Outset the cron service sudo service crond showtime
  2. Edit the crontab file using crontab -e
  3. Add the file path of the file you desire to run. Striking the " i " key to start editing the file and then add 0 */1 * * * python path/to/file . Make sure you give the full path to the python script that you want to run.

verbrugghentheacted.blogspot.com

Source: https://praneeth-kandula.medium.com/running-python-scripts-on-an-aws-ec2-instance-8c01f9ee7b2f