0

First tested something simple like this, which works:

* * * * * echo "something" > /Users/sam/Desktop/vscode/crontest.txt

Now trying

28 10 * * * /Users/user/Desktop/work/venv/bin/python /Users/user/Desktop/work/py_files/test.py

But nothing is happening.

The python script ingests some data from API, parses JSON and outputs to a local mysql db

engine_insert = sqlalchemy.create_engine('mysql+pymysql://root:password@127.0.0.1:3306/database')
df.to_sql('database', engine_insert, if_exists='append', index=False)

But other simpler crons I also had issue with too like opening a website via browser so may just be a syntax issue with crontab?

stubbsy
  • 33
  • 7

1 Answers1

1

I faced the same issue and I spent literally days to see where is my problem. So, try two things:

1- Follow these steps/instructions: https://stackoverflow.com/a/22744360/2080489

2- If you still facing the issue, try to stop any security module you have that might affect the connection. In my case, I am using Ubuntu so I stoped AppAromr:

sudo systemctl stop apparmor 

or in case you want to disable it

sudo systemctl disable apparmor 

check the app status by doing:

sudo systemctl status apparmor 
  • You may need to reboot your machine after stopping the app.

Hope this would help you.

Abud
  • 71
  • 1
  • 7
  • 1
    It is **not advisable** to stop AppArmor (you can find out more [here](https://wiki.debian.org/AppArmor)). you could however, do this `apt-get install apparmor-utils` and then use `sudo aa-complain /sbin/cron` which would put the application in complain mode. meaning it will only log issues. You can then return it to rule enforcement using `sudo aa-enforce /sbin/cron`. I would also suggest you look at [creating profiles for AppArmor](https://wiki.debian.org/AppArmor/HowToUse#Enabling_profiles) to specify what your application can access. – Faris Nov 05 '21 at 13:01
  • 1
    Got it! Thanks Faris. – Abud Nov 05 '21 at 13:07