Before starting, make sure you have the necessary tools installed:
- Python 3 (with
venv
andpip
support) - Cron for setting up periodic task execution
-
Update package lists and install Python:
sudo apt update sudo apt install python3 python3-venv python3-pip -y
-
Check installed versions of Python and pip:
python3 --version pip3 --version
-
Navigate to the project directory:
cd /path/to/your/project
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies from
requirements.txt
:pip install -r requirements.txt playwright install
-
Open the Cron editor to configure a schedule:
crontab -e
-
Add the following line to run the task every 10 minutes:
*/10 * * * * /path/to/your/project/run_bot.sh >> /path/to/your/project/bot.log 2>&1
This command will run the
run_bot.sh
script every 10 minutes and log outputs tobot.log
. -
Start the Cron service (if it is not already running):
sudo service cron start
To manually run the script, execute the following command:
python ./index.py
- Activate the virtual environment:
source venv/bin/activate
- Deactivate the virtual environment:
deactivate