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.


Use AWS Lambda to automate script execution

If you’re hosting your CANedge1 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.

  1. In your start menu write ‘task scheduler’ and open it
  2. Go to Action/Create Task. Add a name and enable ‘Run with highest privileges’
  3. Enable ‘Run whether user is logged on or not’ (requires password)
  4. In Triggers/New, set ‘Repeat task every’ to e.g. 1 hour (and run ‘indefinitely’)
  5. In Actions/New, browse to your main.bat and set the ‘Start in’ to the folder
Windows Task Scheduler Script Automation

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.