0

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

Cron job logs

Any pointers appreciated.

Jenkins B
  • 15
  • 2
  • Are these run from `[uesr]`'s crontab? There should be no need to `cd` then; cron jobs by definition start in the invoking user's home directory. – tripleee Jun 07 '20 at 05:39
  • The logs show that your job *is* running, but that you are throwing away any diagnostic output. – tripleee Jun 07 '20 at 05:41
  • If the duplicate deesn't solve your problem, at the very least it should show a more exhaustive list of things to check before asking again, and what diagnostics to include in a well-defined question. – tripleee Jun 07 '20 at 05:46

0 Answers0