I'm starting a script every day with a cronjob:
0 1 * * * /bin/bash /home/performanceRatio.sh
Script:
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
python3 /home/get_weather_data_crn.py &&
python3 /home/pv.py
The script is running but writing just NULL to the mysql database:
| 2021-02-03 13:00:00 | 48.17 | 11.14 | NULL | NULL | NULL | NULL | 20 | 1 | CRN |
| 2021-02-03 14:00:00 | 48.17 | 11.14 | NULL | NULL | NULL | NULL | 20 | 1 | CRN |
| 2021-02-03 15:00:00 | 48.17 | 11.14 | NULL | NULL | NULL | NULL | 20 | 1 | CRN |
| 2021-02-03 16:00:00 | 48.17 | 11.14 | NULL | NULL | NULL | NULL | 20 | 1 | CRN
It is getting data from CAMS (a weather service). When starting the script manually it works as it should. The database connection seems to work, it's just not writing the weather values as expected when run with Cron. The other values are written.
Using: Ubuntu 20.04
It's written to the db with:
engine = create_engine('mysql+pymysql://{}:{}@{}/{}'.format(user, passwd, host, database))
df.to_sql(con=engine, name=name, if_exists='append', index = True, chunksize=1000)