I am unable to run the python test script below via cron to generate a csv output.
#!/usr/bin/env python3
import pandas as pd
cars = {'Brand': ['Honda Civic','Toyota Corolla','Ford Focus','Audi A4'],
'Price': [22000,25000,27000,35000]
}
df = pd.DataFrame(cars, columns = ['Brand', 'Price'])
df.to_csv('dftestfile2.csv', index=False)
Did research on similar questions asked [1, 2]. I have tried these different cron commands created with sudo crontab -e
to no success:
* * * * * cd /home/[user] && /usr/bin/python3 test.py * * * * * /usr/bin/python3 /home/[user]/test.py * * * * * cd /home/[user] && /usr/bin/python3 /home/[user]/test.py
I have also
- Made my script executable with
chmod +x test.py
- Ensured CRON is running using
sudo service cron status
- Ensured the paths are correct
/usr/bin/python
and/home/[user]/test.py
Any pointers appreciated.