Automate your Python script
You’ve now verified that you can write data to InfluxDB and display it in Grafana. The next step is to automate the data processing so that new data is automatically written to InfluxDB.
Table of Contents
Use AWS Lambda to automate script execution
If you’re hosting your CANedge2 data on AWS S3, we recommend using AWS Lambda functions for automation - see the AWS Lambda README in the CANedge InfluxDB Writer project.
Note
The repo provides ‘deployment scripts’ that let you setup AWS Lambda functions in minutes
Use Windows Task Scheduler to automate script execution
If you want to run the script on a Windows PC, you can use Task Scheduler for automation.
- In your start menu write ‘task scheduler’ and open it
- Go to Action/Create Task. Add a name and enable ‘Run with highest privileges’
- Enable ‘Run whether user is logged on or not’ (requires password)
- In Triggers/New, set ‘Repeat task every’ to e.g. 1 hour (and run ‘indefinitely’)
- In Actions/New, browse to your
main.bat
and set the ‘Start in’ to the folder
To test it, go to the Task Scheduler Library, right-click your task and run. The script will now process log files from local disk or S3 that have not yet been added to your InfluxDB database.